Files
pdfcraft/crates/render
Claude 556db2af72 M2: a JPX image on a rotated page draws instead of crashing (#3884)
The decode-size hint `image_draw_size` hands hayro-jpeg2000 mapped the
image's corners (w, 0) and (0, h) as points, so it took in the
translation. On a /Rotate 90 page (Acrobat Paper Capture scans) one
corner lands on the device origin, the hint gets a side of 0, and
hayro-jpeg2000 0.3.5 divides the image size by it: "renderer crashed on
page N: attempt to divide by zero" on every rotated JPX page.

The hint now comes from the transform's linear part (the axis lengths
the preview tiny-image check already used, now computed once), and each
side is at least 1. As a side effect, translated JPX images no longer get
an overestimated hint, so they can decode at a reduced resolution level
when drawn small, which is what the hint is for.

Regression test: a 1x1 JPX image filling a 40x40 page at /Rotate 0, 90,
180 and 270, rendered at 0.5x, 1x and 1.5x. It fails before the fix
(/Rotate 90 at 0.5x: attempt to divide by zero) and passes after.

Supersedes the guard in #1883 and does not depend on the hayro-jpeg2000
bump in #2309; both are open and conflicting with main.

Fixes #3884

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C19EMwwBCMSkqew7KepPV2
2026-10-30 14:05:47 +00:00
..