]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
UI/jpeg exif orientation (#24196)
authorPascal <redacted>
Fri, 12 Jun 2026 08:20:27 +0000 (10:20 +0200)
committerGitHub <redacted>
Fri, 12 Jun 2026 08:20:27 +0000 (10:20 +0200)
commit6471e3c090107fb0421bd2d59b83f0bb8df8b58f
tree3a137588b8759ca295089e3654be30a1b7686328
parent88a39274ecf88ba11686acd357b59685b1cbf03d
UI/jpeg exif orientation (#24196)

* ui: bake jpeg exif orientation into uploaded images

stb_image in mtmd ignores exif metadata, so rotated smartphone photos
reach the model with raw pixel orientation. The webui now reads the
exif orientation tag at send time and feeds it into the existing
capImageDataURLSize canvas pass: the browser applies the rotation when
decoding, so capped images come out upright for free, and images under
the cap threshold get a single plain redraw when orientation > 1.

At most one re-encode ever happens per image. Upright jpegs with
capping disabled pass through untouched, bit perfect.

Adds jpeg-orientation.ts with a minimal exif parser working on a
bounded base64 prefix (both endianness, returns 1 on any malformed
input) and unit tests against handcrafted jpeg byte streams.

* ui: move jpeg exif constants into lib/constants

* ui: add browser test for jpeg orientation and capping

Covers capImageDataURLSize end to end in chromium with real Pillow
generated jpeg fixtures across exif orientations 1/3/5/6/8: upright
quadrant colors checked pixel-wise, expected dimensions with and
without capping, no orientation tag left in the output, and strict
passthrough when nothing needs rewriting.
tools/ui/src/lib/constants/jpeg-exif.ts [new file with mode: 0644]
tools/ui/src/lib/services/chat.service.ts
tools/ui/src/lib/utils/cap-img-size.ts
tools/ui/src/lib/utils/jpeg-orientation.ts [new file with mode: 0644]
tools/ui/tests/client/cap-img-size.svelte.test.ts [new file with mode: 0644]
tools/ui/tests/unit/jpeg-orientation.test.ts [new file with mode: 0644]