Issues / #1229

#1229 serve: phone photos reach the model rotated by 90° (EXIF Orientation is ignored)

closed · @crazyaimachine · 1 评论 · 在 GitHub 查看

Server & APIModels & quants

描述

**Problem.** Most phones save a portrait photo as a landscape JPEG and only set the EXIF tag `Orientation` (6 or 8). `Vision.normalize()` in `serve/server.py` passes JPEGs through unchanged, and strata-vision's decoder (stb_image) ignores EXIF. So the model sees the photo turned sideways. In OpenWebUI the model told me several times that my images were rotated by 90°, and it was right.

**Fix.** The fix is a small patch to `serve/server.py`, attached as `strata-exif-orientation.patch`. It applies to current `main` with `git apply`.

- A JPEG with an EXIF `Orientation` other than 1 no longer passes through. It goes the Pillow route instead: `ImageOps.exif_transpose()`, then PNG, as other formats already do.
- JPEGs without the tag, and PNG, BMP and GIF, are unchanged and still pass through byte for byte.
- Without Pillow, `_exif_rotated()` returns False, so the behaviour stays as today.

**Checked.**
- A 40×20 test JPEG with `Orientation = 6` comes out as a 20×40 PNG.
- The same JPEG without the tag comes out byte-identical to the input.
- It runs live on my server: 2× TITAN RTX, UD-Q4_K_XL, images through OpenWebUI.

Written by my agent, tested on my machine.

[strata-exif-orientation.patch](https://github.com/user-attachments/files/33118849/strata-exif-orientation.patch)

站内延伸阅读

链到安装、模型与版本说明,便于 SEO/GEO,非官方 issue 正文。