Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Saving grayscale images as AVIF fails with libavif older than 1.3.0

クローズ
#10,262 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #10263 @lazerg による — マージ済み

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, python
領域
backend, data

調査の方向性

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python-pillow/Pillow のほかの issue

python-pillow/Pillow の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。