Skip to content

fix(codegen): avoid cropping exported image fills twice - #45

Merged
owjs3901 merged 2 commits into
mainfrom
integration/cropped-export
Sep 13, 2026
Merged

fix(codegen): avoid cropping exported image fills twice#45
owjs3901 merged 2 commits into
mainfrom
integration/cropped-export

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

about-422-3376 was the worst screen in the corpus at 7.46%, and its page height was exactly right - 7240 against a design height of 7240. Every defect fixed here so far has been vertical. This one was not: the content was mis-composed inside a correct height.

The cause is a double crop.

A CROP image fill carries its framing as a matrix over the image's own 0..1 space, and the generator read that matrix and turned it into a CSS background-position/background-size. That would be correct if the file being positioned were the original image. It is not. image_fill_source names a node.exportAsync rendition, and Figma has already applied imageTransform when producing those pixels. Applying the matrix again framed an already-framed picture.

That also explains why the earlier attempt to honour the crop looked like a fix - the symptom was real, the photographs genuinely were wrong - while measuring worse.

A cropped fill now maps its exported frame once onto its layout box. FIT, FILL and TILE are unchanged, and image_crop is deleted rather than left for someone to reach for again.

Screen Width Before After
about-422-3376 360 7.46% 5.51%
about-422-3180 992 4.06% 3.01%
about-422-2987 1920 2.41% 1.77%

All three widths improve, page heights unchanged, and the other twelve screens are byte-identical.

Verification

Measured independently in the main checkout with binaries built from main and from this branch, full 15-screen acquire and render on each side. My figures match the worker's to the decimal. The baseline run also fails correctly against the new thresholds (7.46% > 5.51%), which confirms the two runs really are measuring different code rather than reusing inputs.

The change is a net deletion. No viewport, breakpoint, node id or capture-specific constant - I grepped the added lines. All 268 plugin byte-parity goldens unchanged. Korean wordBreak: keep-all untouched. Only the three measured about thresholds lowered.

The responsive_screen expectation that asserted the old doubled crop (53.51% -25.92%/91.26% 104.43%) is corrected, with a comment stating why the export is mapped once.

Gates: fmt 0, clippy --locked --workspace --all-targets --all-features -D warnings 0, cargo test --workspace 1070 passed / 0 failed / 2 ignored, insta --check no drift.

@owjs3901
owjs3901 merged commit ee7fc6d into main Sep 13, 2026
8 checks passed
@owjs3901
owjs3901 deleted the integration/cropped-export branch September 13, 2026 05:35
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