Skip to content

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

Closed

Description

@crazyaimachine

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

Activity

  1. Niko1221 commented on Oct 7, 2026

    @Niko1221
    Owner

    Fixed in 0.1.40.2: a JPEG with an EXIF Orientation other than 1 is turned upright (Pillow, then PNG) before the encoder reads it. JPEGs without the tag, PNG, BMP and GIF pass through byte for byte, and without Pillow nothing changes. Thanks for the patch and the checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions