Skip to content

Default animation.convert_args to ["-layers", "OptimizePlus"]. #23371

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2022

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 29, 2022

On the simple_anim.py example, adding e.g.

plt.rcParams["animation.writer"] = "imagemagick"
plt.rcParams["animation.convert_args"] = []
ani.save("old.gif")
plt.rcParams["animation.convert_args"] = ["-layers", "OptimizePlus"]
ani.save("new.gif")

shows that OptimizePlus yields a >2.5x decrease in gif size. (Admittedly I haven't tried more examples.)

Goes on top of #23370. Supersedes #15784. Thanks to @erelson for suggesting to use -layers.

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@dopplershift
Copy link
Contributor

This can be rebased on main now that #23370 is merged.

On the simple_anim.py example, adding e.g.
```
plt.rcParams["animation.writer"] = "imagemagick"
plt.rcParams["animation.convert_args"] = []
ani.save("old.gif")
plt.rcParams["animation.convert_args"] = ["-layers", "OptimizePlus"]
ani.save("new.gif")
```
shows that OptimizePlus yields a >2.5x decrease in gif size.
@anntzer
Copy link
Contributor Author

anntzer commented Jun 29, 2022

rebased.

@QuLogic
Copy link
Member

QuLogic commented Jun 29, 2022

Do we have a minimum supported ImageMagick version? When was this added?

story645
story645 previously approved these changes Jun 30, 2022
@story645 story645 dismissed their stale review June 30, 2022 02:31

accidentally pushed button

@anntzer
Copy link
Contributor Author

anntzer commented Jun 30, 2022

I don't know when it was added exactly, but https://legacy.imagemagick.org/Usage/anim_opt/ dates back to 2007 and already mentions it.

@jklymak
Copy link
Member

jklymak commented Jun 30, 2022

I'm not really convinced that we should change the defaults like this, but rather users should be choosing these sorts of things depending on their application. This is presumably lossy, and I would guess the lossy-ness depends on the animation.

@dopplershift
Copy link
Contributor

@jklymak Reading the docs linked above, I see limited mention of lossy transformations--and those cases are explicitly mentioned (LZW lossy) as unsupported.

The rest of our animations in h264/mp4 are already using lossy compression, so I don't see it as an issue regardless. We should be providing defaults that make the most sense to the majority of our users. IMO, that means providing out-of-the-box functionality to produce GIF animations that have a good size-quality (image and time to write) tradeoff. So I'm fine with having these enabled since there's an escape hatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants