AOSSIE-Org / AOSSIE-Org/PictoPy

BUG: Thumbnail Generation Silently Fails for Certain PNG Modes

Ouverte
#1,513 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
Python
Étoiles
283
Forks
679
Merge moyen
7 j 2 h
PR mergées (30 j)
3

Description

### 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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.