Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add ImageMagick[File]Writer compression arg#15784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

erelson
Copy link
Contributor

PR Summary

Follow-up to my previous PR#15739. Adding a simplecompress arg toImageMagickWriter andImageMagickFileWriter classes.

Questions

I'm suspecting that the docstring is not done right. Sphinx probably doesn't combine theMovieWriter.__init__() docstring and child class'__init__() docstrings automagically. Never dealt with child classes and shared docstrings when I more heavily used sphinx years ago. Is the correct thing to do here to just duplicate the shared args? From what I've seen looking around, I suspect not?

Also, I'm definitely curious to hear what the optimal approach to testing docstring changes/additions is?make html indocs/ is awfully slow. (d'oh, I see now there is a -O j4 option I can pass; will do that next time)

Further tangents on docs:

  • Is it just an artifact of Ubuntu 18.04 and/or WSL thatpython doesn't point atpython3 by default? I modified the docs Makefile to usepython3, as the format strings in (iirc)conf.py didn't make 2.x happy. I could imagine other distros that are more fully on Python3 do link/bin/python to/bin/python3.
  • Has anyone else ever get the docs to build in WSL's bash? I ended up switching to my linux machine to build the docs, since somehow, (if I understood errors correctly) MSVC++ DLLs were being looked for.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Contributor

@anntzeranntzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I personally don't like the idea of reproducing the imagemagick command line as kwargs. (Also, should this use-layers Optimize or-layers OptimizePlus? (https://www.imagemagick.org/script/command-line-options.php?#layers)). So I'm going to block this but am willing to back out if there's enough support for it.

I think better solutions would be to document this in the docstring of ImageMagickWriter/ImageMagickFileWriter, e.g. "For smaller animation sizes, consider setting extra_args to ["-layers", "OptimizePlus"]" -- or even to turn it on unconditionally.

@dopplershift
Copy link
Contributor

@anntzer Can you further detail your concerns? Right now, the entire purpose ofImageMagickWriter is essentially to "[reproduce] the imagemagick command line as kwargs". I mean it does it in an abstracted form so that users don't need to know esoteric details like-layers OptimizePlus, they just know the much more readily googl-able and readablecompress=True.

@erelson
Copy link
ContributorAuthor

Thanks for the feedback. I agree with@anntzer, in that reproducing common args from a utility as args in python does seem like a code smell.

I would be fully on board with making compression the de-facto behavior. I personally initially presumed that matplotlib's use of ImageMagick would do the obvious method of reducing file size by not making each frame of the .gif full-sized.

Doing the above, I'd be tempted to allow the end-user to disable with ano_compress=True arg, or similar. I don't claim to know the usecases that might commonly exist. However, to do that, it sounds like there isn't an elegant solution to how the docstring beyond putting it in the class's docstring instead of__init__'s as@anntzer mentioned.

RegardingOptimizePlus, I'll play with that and add that in if that seems to generally improve things. The linked documentation sounds like the various optimize options all have their good/bad, so that's another point in favor of allowing ano_compress=True +extra_args for those who really want to tweak output with more control of ImageMagick.

Btw, still curious if there's a faster method of iterating on checking the generated docstings.

@anntzer
Copy link
Contributor

Basically, committing to one's memory that the compress kwarg to ImageMagickWriter improves the size of the movie is a totally non-generalizable knowledge. It doesn't help you if you want to use imagemagick directly (and the imagemagick docs will obviously not point to that kwarg either), and it doesn't help you either if you switch to another animation writer class. Also, if imagemagick decides later to introduce a better optimization flag (OptimizePlusPlus), do we need to keep "compress=True" mapped to Optimize for backcompat?

Re: docs build: yeah, it's a bit of a pain. Builds after the first should be less awfully slow, though.
There are a few places where we use string interpolation to reuse parts of docstrings (see e.g. the spectral docs in mlab.py) but it's a bit of a mess and I would suggest not doing it unless really needed.

@dopplershift
Copy link
Contributor

@anntzer That makes sense.

I guess we can't make it the default then though, because there'd be no way to override...

@anntzer
Copy link
Contributor

anntzer commentedNov 30, 2019
edited
Loading

You can put it as default inrcParams["convert.extra_args"]? Then it's overridable by setting the rcparams.

@dopplershift
Copy link
Contributor

That seems reasonable to me.

@erelson
Copy link
ContributorAuthor

I'll check that out and update the PR sometime in the next week or so 👍

@QuLogic
Copy link
Member

Any progress here?

@erelson
Copy link
ContributorAuthor

I've gotta dig into the rcparams stuff a bit before I can do the suggested changes. Maybe this weekend.

@tacaswelltacaswell added this to thev3.4.0 milestoneApr 10, 2020
@jklymakjklymak marked this pull request as draftSeptember 10, 2020 15:43
@QuLogicQuLogic modified the milestones:v3.4.0,v3.5.0Jan 21, 2021
@QuLogicQuLogic modified the milestones:v3.5.0,v3.6.0Aug 23, 2021
@timhoffmtimhoffm modified the milestones:v3.6.0,unassignedApr 30, 2022
@erelson
Copy link
ContributorAuthor

I don't anticipate digging into this code again, unfortunately. Feel free to close.

@anntzer
Copy link
Contributor

Superseded by#23371. Thanks for the suggestion!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer requested changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@erelson@dopplershift@anntzer@QuLogic@tacaswell@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp