Skip to content

codecs: borrow EXIF when reading PSD and PSB headers - #4640

Merged
dylanmtaylor merged 1 commit into
storytold:mainfrom
Terra854:refactor/psd-borrowed-header-exif
Nov 22, 2026
Merged

dylanmtaylor merged 1 commit into
storytold:mainfrom
Terra854:refactor/psd-borrowed-header-exif

Conversation

@Terra854

@Terra854 Terra854 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

LightCraft reads PSD and PSB header orientation without copying unrelated profile and XMP payloads.

Part of storytold/craft-libs#778 and storytold/craft-libs#786. Claim.

Select the last EXIF record by reference and use the resource IDs from the existing craft-psd pin. Full decode retains the last-record policy for ICC, EXIF and XMP, including its EXIF prefix and lossy XMP handling.

The new generated PSD and PSB regression checks duplicate resources, EXIF orientation and the full decode payloads. The codec suite passed 188 tests with one existing ignore before and after the change. Strict all-target codec Clippy, WebAssembly and workspace formatting passed on Windows with 16 Cargo jobs and test threads.

Summary by CodeRabbit

  • Bug Fixes
    • PSD decoding and header reading now consistently use the last available ICC, EXIF, and XMP metadata resources when duplicates are present.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

PSD decoding now selects the last matching ICC, EXIF, and XMP resources. Header orientation uses the last EXIF resource. Tests cover duplicate metadata resources in PSD and PSB inputs.

Changes: PSD metadata resource selection

Layer / File(s) Summary
Resource lookup and metadata handling
crates/codecs/src/psd.rs
New helpers select the last matching resource. Decoding uses the last ICC, EXIF, and XMP records, while header orientation uses the last EXIF record. Tests check duplicate resources for PSD and PSB, including EXIF prefix stripping and XMP conversion and trimming.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related PRs

  • storytold/lightcraft#4167: Moves PSD resource reading into craft_psd::Head; this change updates how the codec reads the last EXIF record.
  • storytold/lightcraft#4602: Changes how the PSD codec obtains resource data from craft_psd in the same code path.

Suggested reviewers: dylanmtaylor, fredapps

Merge Risk: Minimal · up to 02820

PSD and PSB decoding and header orientation now consistently use the last metadata resource, and tests cover duplicate resources. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title 'codecs: borrow EXIF when reading PSD and PSB headers' matches the main change. The PR changes PSD and PSB header orientation to read the last EXIF resource through borrowing via craft_psd::…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title 'codecs: borrow EXIF when reading PSD and PSB headers' matches the main change. The PR changes PSD and PSB header orientation to read the last EXIF resource through borrowing via craft_psd::ImageResource, and adds regression tests for duplicate metadata resources and EXIF orientation. The title is concise, specific, and states the primary change without a file list or vague terms.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1a81a5a and 028206f.

Files selected for processing: 1

  • crates/codecs/src/psd.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@dylanmtaylor
dylanmtaylor merged commit 03be6b4 into storytold:main Nov 22, 2026
12 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