AOSSIE-Org / AOSSIE-Org/PictoPy

BUG: Thumbnail Generation Silently Fails for Certain PNG Modes

Abierto
#1,513 2 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Python
Estrellas
283
Forks
679
Merge medio
7 d 2 h
PR fusionados (30 d)
3

Descripción

### Is there an existing issue for this?

- [x] I have searched the existing issues

### What happened?

## Images with certain colour modes silently missing from gallery

Images with certain PIL colour modes fail thumbnail generation silently. They are never inserted into the database and never appear in the gallery, with no error shown to the user.

### Root Cause

`image_util_generate_thumbnail` in `backend/app/utils/images.py` uses a denylist to decide when to convert the image before saving as JPEG:

```python
if img.mode in ("RGBA", "P"):
img = img.convert("RGB")

img.save(thumbnail_path, "JPEG")
```

Pillow's JPEG encoder natively supports only four modes: `RGB`, `L`, `CMYK`, `YCbCr`. The guard only catches `RGBA` and `P`, missing `LA` (greyscale + alpha), `I` (32-bit integer), and `F` (32-bit float) all valid and common image modes. For any of these, Pillow raises `cannot write mode X as JPEG`, `image_util_generate_thumbnail` returns `False`, the record is never written to the database, and the image is invisible to the user.

### Record

- [x] I agree to follow this project's Code of Conduct

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.