FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Register 'avif' format when available in Pillow by AndrGutierrez · Pull Request #30363 · matplotlib/matplotlib · GitHub

Repository navigation

Register 'avif' format when available in Pillow - #30363

Merged
QuLogic merged 9 commits into
matplotlib:mainfrom
AndrGutierrez:bugfix-for-issue-28809
Jul 30, 2025
Merged

QuLogic merged 9 commits into
matplotlib:mainfrom
AndrGutierrez:bugfix-for-issue-28809

Conversation

AndrGutierrez commented Jul 27, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

PR summary

closes #28809

This fixes the error
ValueError: Format 'avif' is not supported (supported formats: eps, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff, webp) mentioned when saving a .avif figure by doing fig.savefig('test.avif') .

I am not sure if I should add new tests for this, however I got the same results I got when merging the main branch so I would like feedback on that

PR checklist

AndrGutierrez marked this pull request as ready for review July 28, 2025 01:11
AndrGutierrez marked this pull request as draft July 28, 2025 02:20

anntzer commented Jul 28, 2025

Copy link
Copy Markdown
Contributor

I don't think we can merge this until we require Pillow 11.2.1 (the first version to support avif).
More generally, I also wonder whether it makes sense to add support in such a piecemeal fashion, or whether we should have a more general "forward-all-these-formats-to-pillow" mechanism... (does pillow allow listing the formats it supports?)

timhoffm commented Jul 28, 2025 •
edited
Loading

Copy link
Copy Markdown
Member

Well, the formats are not changing that often, so that piecemeal can be good enough. The problem with the version exists, but is bearable. People will get an error message if their pillow is too old. Maybe check if that message is good enough or whether we should provide a better message.

does pillow allow listing the formats it supports?

From a quick look, I did not see anything in the documentation, but AI suggests

# Get the list of supported formats for opening images
supported_open_formats = Image.OPEN.keys()

# Get the list of supported formats for saving images
supported_save_formats = Image.SAVE.keys()

would need investigation what exactly is in there and whether we can use it.

Edit: Actually, this can be done via PIL.features

timhoffm commented Jul 28, 2025 •
edited
Loading

Copy link
Copy Markdown
Member

Please add a test test_pil_kwargs_avif() similar to the existing test_pil_kwargs_* tests here

def test_pil_kwargs_png():

Note: Use the feature query like here to selectively skip the test

@pytest.mark.skipif(not features.check("webp"), reason="WebP support not available")

AndrGutierrez commented Jul 28, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Ok so I added the test for transparency too, and the kwargs test is basically a copy of the webp test that checks compression quality and kwargs, tell me if there is anything else that should be tested in there.

Copy link
Copy Markdown
Contributor Author

Test for ubuntu ARM failed, is this a problem? it seems that it just disconnected, I doubt I made something that makes it fail

AndrGutierrez marked this pull request as ready for review July 28, 2025 18:34

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Minor suggestions

AndrGutierrez and others added 5 commits July 29, 2025 15:25
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>

Copy link
Copy Markdown
Contributor Author

Thank you so much for your feedback Tim :)

Copy link
Copy Markdown
Contributor Author

closed by accident lol

AndrGutierrez reopened this Jul 29, 2025

QuLogic 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Minor issues.

Comment thread lib/matplotlib/backend_bases.py Outdated
Comment thread lib/matplotlib/backends/backend_agg.py Outdated
AndrGutierrez and others added 2 commits July 30, 2025 12:09
QuLogic changed the title FIX: ValueError: Format 'avif' is not supported Register 'avif' format when available in Pillow Jul 30, 2025
QuLogic merged commit 4a60fac into matplotlib:main Jul 30, 2025
QuLogic added this to the v3.11.0 milestone Jul 30, 2025

QuLogic commented Jul 30, 2025

Copy link
Copy Markdown
Member

Thanks @AndrGutierrez! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again.

AndrGutierrez commented Jul 30, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

It was a very nice experience, thank you for all the feedback, I will try to contribute more so ping me if there is something I can help with

QuLogic commented Jul 31, 2025

Copy link
Copy Markdown
Member

Feel free to join our New Contributors Meeting or #incubator channel: https://matplotlib.org/devdocs/devel/contribute.html#new-contributors

AndrGutierrez deleted the bugfix-for-issue-28809 branch August 3, 2025 17:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

[ENH]: Support avif as output format

4 participants


Back | FazBrowse Home | New Git URL