Skip to content

Keep shrink-on-load from moving the projection - #1

Open
kbond wants to merge 1 commit into
altophp:mainfrom
kbond:fix-shrink-on-load-projection
Open

Keep shrink-on-load from moving the projection#1
kbond wants to merge 1 commit into
altophp:mainfrom
kbond:fix-shrink-on-load-projection

Conversation

@kbond

@kbond kbond commented Sep 4, 2026

Copy link
Copy Markdown

Same file, same transform: GD returns 100x120, imagick throws. Scaling a 563x678 JPEG to width 100 decodes at 141x170 under shrink-on-load, and the pipeline solves the resize against that raster rather than the source the plan measured, so it lands on 100x121 and the driver refuses its own work. Any JPEG whose dimensions aren't block-aligned can hit it - over a sweep of 458 such sizes, inside=800x drifts on 38%.

hint() now climbs past any rung the plan doesn't project the same way, so the shrink survives where it's safe (93-100% of those sizes) instead of being abandoned. The corpus gains an unaligned JPEG, since the existing two are 600x400 and 400x600 and every rung of them is exact - which is why neither ProjectionAccuracyTest nor CrossDriverEquivalenceTest could see this. With the fixture and without the fix, both go red.

Found while writing an alto/image transformer for zenstruck/image.

A decode rung that is not a proportional shrink of the source makes the
pipeline solve geometry against a raster the plan never measured, so
`hint()` now climbs past any rung the plan does not project the same way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant