Repository navigation
fix: apply the EXIF orientation when loading document images - #5246
PeterStaar-IBM merged 1 commit into
Conversation
A camera stores the sensor readout and an EXIF orientation tag rather than rotated pixels, and browsers show an <img> turned by that tag. The shared ImageResourceLoader and the MHTML branch of the HTML backend ignored it, so a portrait photo in an HTML, MHTML, Markdown, AsciiDoc, JATS or EPUB document became a sideways picture with its width and height swapped. The image backend already applies the tag (docling-project#4247). Apply ImageOps.exif_transpose after the image is decoded in both places. Signed-off-by: Mohammad Sohail Shaikh <[email protected]>
|
✅ DCO Check Passed Thanks @sohailshk, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit This pull request applies the EXIF orientation tag when Topic labels added: CI safety: no concern found. A maintainer must still approve CI. 2 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 1993454407. It read the code and did not run it.
I found no merge-blocking issue. ImageOps.exif_transpose is called after img.load(), so the pixel-limit check still runs before decode. It is called before the DPI read and normalize_image_for_png. The helper ImageResourceLoader.create_image_ref() and the MHTML branch in _create_image_ref are the only Image.open sites in the HTML-family paths. Both tests assert the swapped size and the corner position, so they check the defect.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
A camera stores the sensor readout and an EXIF orientation tag, not rotated pixels, and browsers show an
<img>turned by that tag.ImageResourceLoader.create_image_ref()and the MHTML branch ofHTMLDocumentBackendignored the tag. A portrait photo in an HTML, MHTML, Markdown, AsciiDoc, JATS or EPUB document therefore became a sideways picture with its width and height swapped.ImageDocumentBackendalready applies the tag (#4247).This change calls
ImageOps.exif_transposeafter the image is decoded, in both places, as #4247 does for image pages. The DPI read after it is unchanged:exif_transposekeepsinfo.Issue resolved by this Pull Request:
Resolves #5245
Checklist:
Review evidence:
Orientation=6, as<img>data URI (HTML) and(Markdown),fetch_images=Truecid:part of an MHTML archivetest_create_image_ref_applies_exif_orientationintests/test_image_resource_loader.pycovers the shared loader (HTML, Markdown, AsciiDoc, JATS and EPUB use it).test_embedded_image_follows_exif_orientationintests/test_backend_mhtml.pycovers the MHTML branch, which decodes on its own.main(assert (200, 100) == (100, 200)) and pass with the change.pytest tests/test_image_resource_loader.py tests/test_backend_mhtml.py tests/test_backend_html.py tests/test_backend_markdown.py tests/test_backend_markdown_images.py tests/test_backend_asciidoc.py tests/test_backend_jats.py tests/test_backend_jats_sub_articles.py tests/test_backend_jats_table_footnotes.py tests/test_backend_epub.py: 567 passed, 2 skipped.prek run --files <changed files>(whatmake validateruns): all hooks passed (Ruff v0.17.2, Ruff format, ty 0.0.33, Tach, license header, max lines).