Skip to content

fix(cli): respect image orientation in capture contact sheets - #5295

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/capture-contact-sheet-orientation
Oct 24, 2026
Merged

jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/capture-contact-sheet-orientation

Conversation

@user-github-me

Copy link
Copy Markdown
Contributor

What

Respect EXIF orientation in downloaded-asset contact sheets: use displayed dimensions for the grid and orient every thumbnail before resizing.

Why

hyperframes capture downloads an EXIF-oriented portrait correctly and screenshots the page upright, but its asset contact sheet displays the same photo sideways. Reproduced on main with Portrait_6.jpg: coded dimensions are 1800×1200, displayed dimensions are 1200×1800. The generated sheet changes from 1940×354 with a sideways photo to 1940×754 with an upright photo.

Related work

No overlapping capture contact-sheet orientation issue or PR found. #5288 addresses orientation in reference-image comparisons; this fixes the separate asset-preview generation path.

How

Read Sharp's auto-oriented metadata for the first cell's aspect ratio and apply autoOrient() before each resize. Downloaded image bytes remain unchanged.

Test plan

  • Unit tests added: all eight JPEG orientations, mirrored pixels, mixed-orientation assets, and unchanged source bytes. Eight regressions fail against main; all 23 contact-sheet/post-extraction/comparison/snapshot tests pass with the fix.
  • Manual testing: actual source and built CLI captures of a local page displaying the public portrait. Both produce upright sheets and preserve the downloaded photo byte for byte; checked output dimensions and pixels against an independently oriented reference.
  • CLI build/typecheck, repository lint, changed-file formatting, test reachability, comment checks, and all commit hooks passed.
  • Documentation changes are unnecessary for this correction. No new code comments; the behavior and reproduction are recorded above.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on main that createContactSheet sizes cells from raw metadata width and height and resizes without orienting, so EXIF-rotated photos land sideways in the asset contact sheet. Using metadata().autoOrient for the first cell's dimensions and calling autoOrient() before each resize fixes both the cell shape and every thumbnail, and it is a no-op for the PNG screenshot sheets that share this function. Both APIs exist in the pinned sharp 0.35. The tests build a quadrant-colored JPEG for all eight orientations and check pixel placement, plus a mixed-orientation asset sheet where only the second image is rotated, so they exercise the real path. Still relevant on main.

— Rames

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026
@jrusso1020
jrusso1020 removed this pull request from the merge queue due to a manual request Oct 24, 2026
@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into heygen-com:main with commit e0317a2 Oct 24, 2026
81 checks passed
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.

2 participants