AOSSIE-Org / AOSSIE-Org/PictoPy

BUG: Thumbnail Generation Silently Fails for Certain PNG Modes

オープン
#1,513 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Python
スター
283
フォーク
679
平均マージ
7日 2時間
マージ済み PR(30日)
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 を短くまとめたダイジェスト。