Saving grayscale images as AVIF fails with libavif older than 1.3.0
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
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
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-pillow/Pillow
-
Warn that pre-applying arabic_reshaper + python-bidi corrupts text on a Raqm buildPosiblemente ocupada @Syamjith-NK la tomó hace 53 días. AbiertoDocumentation Font Rendering PNG Third Party Framework
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
python-pillow/Pillow#9907 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Image.putpixel incorrectly labels supported arguments in type annotationsPosiblemente ocupada @radarhere la tomó hace 181 días. AbiertoPNG
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
python-pillow/Pillow#9584 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Future of JPEG2000 supportAbiertoJPEG
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
python-pillow/Pillow#10241 · 4 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
`frombytes()` and in-place `ImageCms` transforms write into read-only image memoryPosiblemente ocupada @tongwentao la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 50/100
python-pillow/Pillow#10235 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
ImageDraw is not translation-invariant for negative coordinates (truncation toward zero instead of floor)Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
python-pillow/Pillow#10228 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de python-pillow/Pillow
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
[Bug]: Queen's own Ollama model loses num_ctx when a running session switches to itPosiblemente ocupada @anasamin26 la tomó hoy. Abiertobug enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
aden-hive/hive#7508 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
llm translation
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
BerriAI/litellm#47884 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
bug 🐛
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
netalertx/NetAlertX#1856 · 1 reacción ·
Los mantenedores suelen responder en 1 día