8000 Allow saving PNGs through Pillow instead of the builtin _png module. by anntzer · Pull Request #13207 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Allow saving PNGs through Pillow instead of the builtin _png module. #13207

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
Jan 17, 2019

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Jan 17, 2019

PR Summary

(Because Pillow exposes more (most?) PNG options.)
Closes #5397.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

for k, v in metadata.items():
pnginfo.add_text(k, v)
pil_kwargs["pnginfo"] = pnginfo
pil_kwargs.setdefault("dpi", (self.figure.dpi, self.figure.dpi))
Copy link
Member

Choose a reason for hiding this comment

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

This is a little confusing - if the user passes dpi=200 to savefig it will be ignored in lieu of self.figure.dpi? Is there no way to pass the dpi from savefig as the default instead (of course falling back to self.figure.dpi?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See discussion in #13094 (review).

Copy link
Member

Choose a reason for hiding this comment

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

Ah right. I even saw that at the time. (though, maybe a comment here though just to remind the unwary).

Copy link
Member

Choose a reason for hiding this comment

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

This looks fine to me once it passes the test...

@jklymak jklymak merged commit b1e6ac6 into matplotlib:master Jan 17, 2019
@anntzer anntzer deleted the png_pil_kwargs branch January 17, 2019 20:48
8000
@QuLogic QuLogic added this to the v3.1 milestone Jan 18, 2019
user_metadata = kwargs.pop("metadata", None)
if user_metadata is not None:
metadata.update(user_metadata)
if metadata is None:
Copy link

Choose a reason for hiding this comment

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

Randomly surfing this change from a watched issue

Why initing metadata = {} is just a line below it's inited to something else again?

https://github.com/anntzer/matplotlib/blob/9c7f926d6d70a994c3710ce570bb9807519ef090/lib/matplotlib/backends/backend_agg.py#L509

Copy link
Member

Choose a reason for hiding this comment

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

It's used on line 513.

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

Successfully merging this pull request may close these issues.

Expose compression and filter PNG options through savefig
5 participants
0