Skip to content

Allow passing arguments to PIL.Image.save().#13094

Merged
efiring merged 1 commit into
matplotlib:masterfrom
anntzer:pil_kwargs
Jan 17, 2019
Merged

Allow passing arguments to PIL.Image.save().#13094
efiring merged 1 commit into
matplotlib:masterfrom
anntzer:pil_kwargs

Conversation

@anntzer

@anntzer anntzer commented Jan 3, 2019

Copy link
Copy Markdown
Contributor

PR Summary

Closes #8530; more general than #8531 (this way we don't need to implement each and every kwarg separately).
Unfortunately, does not help with #5397 as png output does not go though pillow.

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

Comment thread lib/matplotlib/backends/backend_agg.py
@tacaswell tacaswell added this to the v3.1 milestone Jan 4, 2019
@tacaswell

Copy link
Copy Markdown
Member

👍 in principle, but needs a test.

@anntzer

anntzer commented Jan 4, 2019

Copy link
Copy Markdown
Contributor Author

Test added. (Explicitly not testing compression for tiff as that requires pillow+libtiff and I'd rather write something independent of whether libtiff is installed.)
I realized we could also fix #5397 by having png-saving also go through pillow when pil_kwargs is not None, but that'll be a separate PR after this one.

Comment thread lib/matplotlib/backends/backend_agg.py Outdated
Comment thread lib/matplotlib/figure.py Outdated
Comment thread lib/matplotlib/backends/backend_agg.py Outdated

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Conditional on CI passing.

@efiring

efiring commented Jan 17, 2019

Copy link
Copy Markdown
Member

Looks good, but I see a test using pil_kwargs only for TIFF, not for Jpeg. Can the latter be added easily?

@anntzer

anntzer commented Jan 17, 2019

Copy link
Copy Markdown
Contributor Author

@efiring That's because Pillow can be built with or without libjpeg support, and I don't want to bother checking what build variant we have (I'm not even sure what to check or what exception to catch -- if you know, please let me know); on the other hand, Pillow always does have tiff support (as that's pure python).

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.

Feature request: TIFF LZW compression support in savefig()

5 participants