Skip to content

fix(cli): respect reference image orientation in grade comparisons - #5288

Merged
miguel-heygen merged 4 commits into
heygen-com:mainfrom
user-github-me:fix/grade-compare-oriented-reference
Oct 25, 2026
Merged

miguel-heygen merged 4 commits into
heygen-com:mainfrom
user-github-me:fix/grade-compare-oriented-reference

Conversation

@user-github-me

@user-github-me user-github-me commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

grade-compare sizes image cells from the reference's displayed dimensions, including EXIF orientation. Portrait phone photos therefore keep their aspect ratio instead of being fitted into landscape cells. The source image bytes remain unchanged, and the browser retains responsibility for displaying its orientation.

The update to current main preserves lazy loading of Sharp through loadSharp("grade-compare"). The color-grading guide describes the orientation behavior.

Validation: the full workspace build, CLI typecheck, 19 grade-compare tests, lint/formatting, test reachability, normal commit hooks, both comment checks, and Mintlify validation/broken-link checks pass. The tests cover all eight EXIF orientations and a PNG control. An actual built-CLI run on Chrome 152 produced a 1168×1184 comparison sheet for an EXIF-6 portrait JPEG and left the input bytes unchanged.

Additional native visual validation at this head: the actual grade-compare command was run on a 640×320 JPEG with EXIF orientation 6, four asymmetric color quadrants and a centered circle, using Chrome for Testing 152.0.7977.42 on macOS/Apple M4. Both the original and active warm-daylight cells display the expected rotated quadrant order in a 320×640 portrait aspect. In each 560×1120 image cell the circle measures 210×210 pixels, confirming it is not stretched; the active grade changes the measured colors. The sheet is 1168×1184 and the input JPEG remains byte-identical. The resulting sheet was also visually inspected. This verifies orientation and shape inside the graded cells, in addition to sheet dimensions.

@jrusso1020

Copy link
Copy Markdown
Collaborator

Thanks for this, @user-github-me. This PR now has merge conflicts with main. Could you rebase it onto the latest main? Once it's conflict-free we'll review it and get it into the merge queue.

@mintlify

mintlify Bot commented Oct 24, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit b32c4f2.

Approve preview

@miguel-heygen miguel-heygen 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.

Reviewed at b32c4f2. This is a small, well-aimed fix, and the branch now merges cleanly with main.

  • loadReferenceFrame now sizes the cell from sharp's autoOrient dimensions. The CLI pins sharp ^0.35.0, which has that field, and loadSharp only ever loads that version, so there is no older sharp for this to trip on.
  • The tests cover all eight EXIF orientations plus a PNG control, and go from loadReferenceFrame through buildGradeCompareHtml, so they check the sheet height that users actually get. The four rotated orientations fail against the old raw-dimension code, so they pin the fix.
  • Video references are unaffected: the extracted frame is a PNG without orientation metadata, so the dimensions come out the same as before.

One question, not blocking: the graded cells are drawn through WebGL from the <img>, with the canvas sized from naturalWidth/naturalHeight. The description confirms the sheet came out 1168×1184 for an EXIF-6 photo. Did you also check that the graded pictures inside the cells are upright and not stretched? If they are, nothing more is needed. If not, that problem predates this change and could be a follow-up.

Verdict: APPROVE
Reasoning: The dimension fix is correct for every input kind the command accepts, it is pinned by non-vacuous tests, and CI is green on a branch that merges cleanly.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Oct 25, 2026
Merged via the queue into heygen-com:main with commit 39364ee Oct 25, 2026
152 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.

3 participants