fix(pdf): Rotated photo frames print at the angle they preview at - #89
Open
patriksimms wants to merge 1 commit into
Open
fix(pdf): Rotated photo frames print at the angle they preview at#89patriksimms wants to merge 1 commit into
patriksimms wants to merge 1 commit into
Conversation
Summary: - rotate photos, decorative images, and empty-slot filler art around the frame's top-left corner, the corner the preview turns elements around - turn a gallery as one frame by embedding its photos first and wrapping every slot in a single transformation - cover placement with tests that replay the exported page's drawing operators and compare page-space corners - add before/after exported-PDF proofs for a rotated frame with and without a photo Rationale: - pdf-lib's per-call rotate option turns each drawing around its own anchor, which would move a frame instead of turning it and would pull a gallery's slots apart; a transformation matrix turns the clip path, the photo inside it, and every slot together - page space counts Y upwards where CSS counts it downwards, so the preview's clockwise angle is the negated angle in the export - photos and filler art had to move together, or a slot would visibly shift as soon as a contributor added or removed a photo Tests: - bun run format:check - bun run lint - bun run typecheck - bun run test (349 passed; 14 pre-existing failures need the local Postgres and S3 services, which are unavailable here) - bun run build with test Clerk configuration Closes #86 AI-Assisted: true AI-Agent: claude-code AI-Model: anthropic/claude-opus-5
patriksimms
marked this pull request as ready for review
August 24, 2026 21:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A rotated image frame exported axis-aligned. Text already rotated, so a rotated
layout printed with its words at an angle and its pictures square.
Solution
Photos, decorative images, and empty-slot filler art are now drawn inside a
transformation matrix that turns them around the frame's top-left corner — the
corner the preview turns an element around (
transform-origin: top left). Pagespace counts Y upwards where CSS counts it downwards, so the preview's angle is
negated in the export.
pdf-lib's per-call
rotateoption was not usable here: it turns each drawingaround its own anchor, which moves an element instead of turning it in place and
would pull a gallery's slots apart. A gallery therefore embeds its photos before
anything is painted, so one transformation can wrap the whole frame.
In scope
Out of scope
bottom-left corner. Every shipped background preset is deliberately
axis-aligned, and fix(pdf): Rotated frames export axis-aligned instead of rotated #86 scoped this fix to picture content.
Acceptance criteria
crops a photo to the frame at the angle the preview showsrotates a gallery as one frame, keeping its slots in the same relative placesturns a decorative image at the angle the preview showsturns filler art with the frame, so a slot does not move when a photo arrivesleaves an unrotated frame exactly where it wasThe new tests replay the exported page's drawing operators and compare
page-space corners, so they assert where a photo actually lands rather than
which operators pdf-lib happens to write. All four rotation tests fail against
mainand pass here; the axis-aligned test passes both ways.Exported-PDF proof
Rasterised from an exported PDF of the same layout: an image frame at -12°, a
two-slot gallery at 8°, a decorative image at 15°, and a caption at -12° for
reference.
Rotated frames holding photos
The same frames with no photo uploaded
Validation
bun run format:check,bun run lint,bun run typecheckbun run test— 349 passed; the 14 failures need the local Postgres and S3services, which are unavailable in this environment and fail identically on
mainbun run buildwith the CI Clerk test keysbun run test:e2enot run locally (no services or browsers); left to CINo configuration outside the repository is required.
Closes #86