Saving grayscale images as AVIF fails with libavif older than 1.3.0
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #10263 @lazerg による — マージ済み
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 65/100
調査の方向性
Start with AvifImagePlugin._save and the AVIF handling in _avif.c, especially the AVIF_VERSION condition around grayscale format support. Compare the "L" rawmode path with the libavif version checks and run the AVIF save tests against libavif 1.0.4 and a newer version. Done means grayscale modes save successfully with both versions, while the RGB control still works.
索引モデルが issue の本文から書いたものです。
説明
What did you do?
Saved a grayscale image as AVIF with Pillow built from source against the distribution libavif on Ubuntu 24.04 (libavif-dev 1.0.4):
from io import BytesIO
from PIL import Image, features
print("Pillow", Image.__version__, "| libavif", features.version("avif"))
for mode in ("1", "L", "I", "I;16", "F"):
try:
Image.new(mode, (128, 128)).save(BytesIO(), "AVIF")
print(mode, "saved")
except Exception as e:
print(mode, type(e).__name__ + ":", e)
Image.new("L", (128, 128)).convert("RGB").save(BytesIO(), "AVIF")
print("control: L converted to RGB first, saved")
What did you expect to happen?
The images to be saved, as they were before 12.3.0 (which converted them to RGB). The building-from-source docs say Pillow requires libavif 1.0.0 or greater.
What actually happened?
Pillow 13.1.0.dev0 | libavif 1.0.4
1 RuntimeError: rgb data has incorrect size: 384 * 128 (49152) != 16384
L RuntimeError: rgb data has incorrect size: 384 * 128 (49152) != 16384
I RuntimeError: rgb data has incorrect size: 384 * 128 (49152) != 16384
I;16 RuntimeError: rgb data has incorrect size: 384 * 128 (49152) != 16384
F RuntimeError: rgb data has incorrect size: 384 * 128 (49152) != 16384
control: L converted to RGB first, saved
Every grayscale mode fails; converting to RGB first works.
#9471 (12.3.0) made AvifImagePlugin._save pass rawmode "L" for grayscale modes unconditionally, but _avif.c only handles AVIF_RGB_FORMAT_GRAY under #if AVIF_VERSION >= 1030000. With libavif < 1.3.0 the C side packs the data as RGB, so the size check fails. Wheels bundle a newer libavif, so this only affects builds against an older system libavif.
What are your OS, Python and Pillow versions?
- OS: Ubuntu 24.04 (libavif 1.0.4 from apt)
- Python: 3.13.16
- Pillow: main at 95847325 (13.1.0.dev0), built from source
Found and reproduced with AI assistance; the repro above was run by me.
- 主要言語
- Python
- スター
- 13.9k
- フォーク
- 2.5k
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 150
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-pillow/Pillow のほかの issue
-
Warn that pre-applying arabic_reshaper + python-bidi corrupts text on a Raqm build対応中かも @Syamjith-NK が 53 日前に担当しました。 オープンDocumentation Font Rendering PNG Third Party Framework
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
python-pillow/Pillow#9907 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Image.putpixel incorrectly labels supported arguments in type annotations対応中かも @radarhere が 181 日前に担当しました。 オープンPNG
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
python-pillow/Pillow#9584 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
JPEG
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
python-pillow/Pillow#10241 · コメント 4 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`frombytes()` and in-place `ImageCms` transforms write into read-only image memory対応中かも @tongwentao が 1 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
python-pillow/Pillow#10235 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
ImageDraw is not translation-invariant for negative coordinates (truncation toward zero instead of floor)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
python-pillow/Pillow#10228 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
python-pillow/Pillow の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pgvector/pgvector-python#169 ·
-
ChaosEngine: backup-remote doctor row passes while consumer mode hides bot memory from git対応中かも @MohabMohie が今日担当しました。 オープンagentic
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ShaftHQ/SHAFT_ENGINE#7263 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
huggingface/smolagents#3045 ·
メンテナーはふだん 1 日以内に返信