AOSSIE-Org / AOSSIE-Org/PictoPy

BUG: Thumbnail Generation Silently Fails for Certain PNG Modes

未關閉
#1,513 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
283
分支
679
平均合併
7 天 2 小時
30 天內合併 PR
3

描述

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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。