Skip to content

Convert grayscale images to RGB when saving AVIF with libavif < 1.3.0 - #10263

Merged
radarhere merged 3 commits into
python-pillow:mainfrom
lazerg:fix/issue-10262-avif-grayscale-old-libavif
Oct 21, 2026
Merged

radarhere merged 3 commits into
python-pillow:mainfrom
lazerg:fix/issue-10262-avif-grayscale-old-libavif

Conversation

@lazerg

@lazerg lazerg commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #10262.

Changes proposed in this pull request:

  • Since Support opening and saving L mode AVIF images with libavif >= 1.3.0 #9471, grayscale images are passed to _avif with rawmode L, but AVIF_RGB_FORMAT_GRAY is only used with libavif >= 1.3.0. With older libavif the data is still treated as RGB, so saving fails with "rgb data has incorrect size". This only uses L when libavif is 1.3.0 or newer, and converts to RGB otherwise, like before.
  • Added a test that saves grayscale modes without requiring libavif 1.3.0. I checked it against libavif 1.0.4 and 1.4.2.

@lazerg

lazerg commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

The MinGW failure is not from this change. MSYS2 no longer has the mingw-w64-x86_64-python-pyqt6 package, so the "Install dependencies" step fails before the build starts.

@radarhere

Copy link
Copy Markdown
Member

The MinGW issue appears to have resolved itself.

@radarhere
radarhere force-pushed the fix/issue-10262-avif-grayscale-old-libavif branch from 568d77c to 241f558 Compare October 21, 2026 06:24
@radarhere
radarhere force-pushed the fix/issue-10262-avif-grayscale-old-libavif branch from 241f558 to 3e17efb Compare October 21, 2026 09:30
@radarhere
radarhere force-pushed the fix/issue-10262-avif-grayscale-old-libavif branch from 3e17efb to f197058 Compare October 21, 2026 09:31
@radarhere
radarhere enabled auto-merge (squash) October 21, 2026 09:32
@radarhere
radarhere merged commit a6e738c into python-pillow:main Oct 21, 2026
50 checks passed
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.

Saving grayscale images as AVIF fails with libavif older than 1.3.0

2 participants