Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Saving grayscale images as AVIF fails with libavif older than 1.3.0

Cerrado
#10,262 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Ya se ha fusionado un pull request relacionado.

  • #10263 de @lazerg — fusionado

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, python
Área
backend, data

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
13.9k
Forks
2.5k
Merge medio
1 d 2 h
PR fusionados (30 d)
150

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-pillow/Pillow

Todos los issues de python-pillow/Pillow

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.