[ENH]: Support avif as output format
Problem
Since v3.6.0, Matplotlib supports webp output (yay!), but I couldn't find a ticket tracking Avif support, so here's a feature request for savefig to support saving as .avif.
relevant links:
Proposed solution
No response
I think this would need to wait for pillow to support?
While Pillow support is a prerequisite (and probably sufficient) condition for savefig to support AVIF, animations actually may have some support already.
Newer versions of ffmpeg support AVIF (though I could not test easily because the version in my distro's repository is too old).
The imagemagick writer did save an AVIF file. However, it may have only saved a single frame... (Not 100% sure if that is a viewer program problem or file output problem)
ani.save("test.avif", writer="imagemagick")
Gives: (zipped AVIF file because github doesn't allow AVIF directly) test.zip
Good first issue - notes for new contributors
This issue is suited to new contributors because it does not require understanding of the Matplotlib internals. To get started, please see our contributing guide.
We do not assign issues. Check the Development section in the sidebar for linked pull requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please collaborate on the work by reviewing it rather than duplicating it in a competing PR.
If something is unclear, please reach out on any of our communication channels.
Until that PR is merged you can use a separate package, pillow-avif-plugin, to allow Pillow to save AVIF images.
hello, has this been worked on yet? Am I able to work on this as my first issue?
what would be the difficulty level of this issue?
I have successfully added this functionality by adding the pillow-avif-plugin library to all relevant files. I am working on making a pull request with these changes. I added the pillow-avif-plugin library to all the requirements files where pillow is listed, so it is automatically installed.
We want to keep our dependencies small. Therefore, I don't think we should add the plugins to our requirements.
There seems to be progress on this upstream: https://github.com/python-pillow/Pillow/pull/5201
Pillow now supports avif (when built from source) https://pillow.readthedocs.io/en/stable/releasenotes/11.2.1.html
So, would it make sense to try implementing support for AVIF now, or should we wait until it's officially included in the Pillow binaries (if that's supposed to happen)?
Hi! I’d like to work on this issue. Is anyone else already working on it or are there any specific guidelines I should follow? (this is my first contribution)
With Pillow 1.3 avif support is now included in Pillow’s wheels (except some):
https://pillow.readthedocs.io/en/stable/releasenotes/11.3.0.html#avif-support-in-wheels
Is there anything to do on our side? I'd expect that saving will "just work" with 1.3?
Is there anything to do on our side? I'd expect that saving will "just work" with 1.3?
With matplotlib==3.10.3 and pillow==11.3.0 I still get:
> import matplotlib.pyplot as plt
> fig = plt.figure()
> fig.savefig('test.avif')
/.../
`ValueError: Format 'avif' is not supported (supported formats: eps, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff, webp)
Ah, we need to internally register the format. Changes should be analogous to #21274.