Skip to content

Use native Pillow v11.2.0 AVIF format #167

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Stormheg
Copy link
Member

@Stormheg Stormheg commented Apr 1, 2025

Fixes #166

Pillow v11.2.0 was released today with AVIF support as a notable new feature.

Requires raising the minimum version of Pillow. Only the latest Pillow release receives active support so requiring the latest version doesn't seem like a big issue to me. Especially now that AVIF support in pillow-heif is deprecated, as noted in #166

# Quality of 100 implies lossless (according to libavif documentation)
"quality": 100,
# When encoding lossless images, don't use chroma subsampling (4:4:4 retains the most information)
"subsampling": "4:4:4",
Copy link
Member Author

@Stormheg Stormheg Apr 1, 2025

Choose a reason for hiding this comment

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

This isn't a valid option when encoding a grayscale image, should be 4:0:0 instead (grayscale is Pillow L or LA mode image) - something for a follow up?

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's do it as a follow up (as long as you have the time :D)

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried writing a failing test but it turns out save_as_avif will convert from LA to RGBA internally - which makes this not really relevant... or at least not without same yak shaving to figure out why the conversion is happening.

Let's leave this here for now.

@Stormheg Stormheg force-pushed the fix/pillow-11.2-avif-support branch from 398102e to 98948b5 Compare April 1, 2025 16:15
Requires raising the minimum version of Pillow.
@Stormheg Stormheg force-pushed the fix/pillow-11.2-avif-support branch from 98948b5 to 85b6681 Compare April 1, 2025 16:17
@Stormheg
Copy link
Member Author

Stormheg commented Apr 15, 2025

Marking as draft for now, this needs more work (upstream)

The Pillow 11.2.0 release was retracted because the added AVIF encoders/decorders severely increased the size of prebuilt wheels, causing the project to hit its PyPI upload limit which resulted in not all platforms having a prebuilt 11.2.0 wheel available. As a result, 11.2.1 was released which no longer ships with the libavif library included by default. 1 Including libavif requires building from source, which is a hassle.

This poses an issue for this PR as we can no longer assume AVIF support is available.

The Pillow maintainers have indicated that they will revisit the issue in 11.3.0, so let's cross our fingers and hope they manage to fix the issue 2.

Footnotes

  1. https://github.com/python-pillow/Pillow/blob/7a0092f2072a5deca433e2a6b752eced49e4ee16/docs/releasenotes/11.2.1.rst?plain=1#L6-L10

  2. https://github.com/python-pillow/Pillow/pull/8876#issuecomment-2798906089

@Stormheg Stormheg marked this pull request as draft April 15, 2025 14:39
@Stormheg Stormheg added the component: Dependencies Pull requests that update a dependency file label Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AVIF support in pillow-heif is deprecated
2 participants