Skip to content

Include dimensions in metadata#72

Merged
meesoft merged 2 commits intomainfrom
features/ImageDimensions
Mar 6, 2026
Merged

Include dimensions in metadata#72
meesoft merged 2 commits intomainfrom
features/ImageDimensions

Conversation

@meesoft
Copy link
Owner

@meesoft meesoft commented Mar 4, 2026

Summary by CodeRabbit

  • New Features

    • Image metadata now includes dimension information (width x height).
  • Bug Fixes

    • Improved handling of single-input video processing scenarios.
    • Applied consistent default frame rate (30 FPS) throughout video processing workflows.
  • Refactor

    • Enhanced metadata extraction reliability with frame-based decoding approach.

@meesoft meesoft marked this pull request as ready for review March 6, 2026 21:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

Walkthrough

Modified metadata string construction in ExifHandler to incorporate image dimensions (WIDTHxHEIGHT format) and switched from file-based metadata loading to BitmapDecoder frame-based extraction. Updated VideoTransformCommands to introduce a DefaultFrameRate constant and replace hard-coded frame rate values throughout multiple processing code paths, including conditional loop handling for non-video inputs.

Changes

Cohort / File(s) Summary
Metadata Dimension Integration
PhotoLocator/Metadata/ExifHandler.cs
Modified GetMetadataString to accept and conditionally append width/height dimensions; switched metadata retrieval from LoadMetadata(file) to BitmapDecoder.Create(...).Frames[0] with dimension extraction from frame properties and fallback handling.
Frame Rate Standardization
PhotoLocator/VideoTransformCommands.cs
Introduced DefaultFrameRate constant (30) and replaced hard-coded frame rate values across processing paths; added conditional "-loop 1" for non-video inputs before duration application; adjusted frame rate fallback logic in multiple processing scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Fix orientation after edit #65 — Modifies ExifHandler.cs and DecodeMetadataAsync with metadata handling updates that overlap with the width/height-aware extraction changes in this PR.
  • Effect parameter titles #69 — Modifies VideoTransformCommands.cs with DefaultFrameRate fallback and UpdateProcessArgs handling, directly related to the frame rate constant introduction and processing argument construction.
  • Video effects and cropping #26 — Modifies VideoTransformCommands.cs for video processing behavior adjustments that affect the same input handling and frame rate processing paths.
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Include dimensions in metadata' directly matches the main change: reworking metadata string construction to incorporate image dimensions into the metadata output.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch features/ImageDimensions

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
PhotoLocator/Metadata/ExifHandler.cs (1)

647-659: ⚠️ Potential issue | 🟠 Major

Use orientation-adjusted dimensions here.

For EXIF orientations 6 and 8, frame.PixelWidth/frame.PixelHeight are the stored raster dimensions, not the displayed ones. Portrait photos will therefore show reversed dimensions in the new metadata string.

💡 Proposed fix
                 var orientation = orientationValue switch
                 {
                     3 => Rotation.Rotate180,
                     6 => Rotation.Rotate90,
                     8 => Rotation.Rotate270,
                     _ => Rotation.Rotate0
                 };
                 var timeStamp = DecodeTimeStamp(metadata, file);
-                return (GetGeotag(metadata), timeStamp, GetMetadataString(metadata, frame.PixelWidth, frame.PixelHeight, timeStamp), orientation);
+                var (displayWidth, displayHeight) = orientation is Rotation.Rotate90 or Rotation.Rotate270
+                    ? (frame.PixelHeight, frame.PixelWidth)
+                    : (frame.PixelWidth, frame.PixelHeight);
+                return (GetGeotag(metadata), timeStamp, GetMetadataString(metadata, displayWidth, displayHeight, timeStamp), orientation);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@PhotoLocator/Metadata/ExifHandler.cs` around lines 647 - 659, The code uses
frame.PixelWidth/frame.PixelHeight (stored raster dimensions) when building the
metadata string and in the early null-metadata return, which is wrong for
orientation 6/8; compute displayedWidth and displayedHeight after computing
orientation (swap when orientation is Rotation.Rotate90 or Rotation.Rotate270)
and use those displayed dimensions in the early return string and in the call to
GetMetadataString (replace frame.PixelWidth/frame.PixelHeight with
displayedWidth/displayedHeight); keep the rest of the logic (orientationValue,
DecodeTimeStamp, GetGeotag) unchanged and reference BitmapDecoder.Create,
orientationValue/orientation, OrientationQuery1/OrientationQuery2,
GetMetadataString, and the early "if (frame.Metadata is not BitmapMetadata
metadata) return ..." branch when applying the change.
🧹 Nitpick comments (1)
PhotoLocator/Metadata/ExifHandler.cs (1)

584-585: This overload still omits the new dimensions token.

GetMetadataString(BitmapMetadata, Stream?) now hardcodes (0, 0), so callers of this public overload still get the old metadata format while DecodeMetadataAsync gets the new WIDTHxHEIGHT token. Consider deriving dimensions here as well, or collapsing call sites onto the width/height-aware path so the output stays consistent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@PhotoLocator/Metadata/ExifHandler.cs` around lines 584 - 585, The public
overload GetMetadataString(BitmapMetadata, Stream?) currently calls
GetMetadataString(metadata, 0, 0, DecodeTimeStamp(metadata, imageStream)) which
hardcodes width/height and omits the new WIDTHxHEIGHT token; update this
overload to derive actual image dimensions (e.g., read pixel width/height from
the BitmapMetadata or the provided imageStream) and pass them into
GetMetadataString(metadata, width, height, DecodeTimeStamp(...)) or refactor
callers to use the width/height-aware path so the output includes the new
dimensions token consistently (look for the GetMetadataString overloads and
DecodeTimeStamp usage to modify the correct method).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@PhotoLocator/Metadata/ExifHandler.cs`:
- Around line 647-659: The code uses frame.PixelWidth/frame.PixelHeight (stored
raster dimensions) when building the metadata string and in the early
null-metadata return, which is wrong for orientation 6/8; compute displayedWidth
and displayedHeight after computing orientation (swap when orientation is
Rotation.Rotate90 or Rotation.Rotate270) and use those displayed dimensions in
the early return string and in the call to GetMetadataString (replace
frame.PixelWidth/frame.PixelHeight with displayedWidth/displayedHeight); keep
the rest of the logic (orientationValue, DecodeTimeStamp, GetGeotag) unchanged
and reference BitmapDecoder.Create, orientationValue/orientation,
OrientationQuery1/OrientationQuery2, GetMetadataString, and the early "if
(frame.Metadata is not BitmapMetadata metadata) return ..." branch when applying
the change.

---

Nitpick comments:
In `@PhotoLocator/Metadata/ExifHandler.cs`:
- Around line 584-585: The public overload GetMetadataString(BitmapMetadata,
Stream?) currently calls GetMetadataString(metadata, 0, 0,
DecodeTimeStamp(metadata, imageStream)) which hardcodes width/height and omits
the new WIDTHxHEIGHT token; update this overload to derive actual image
dimensions (e.g., read pixel width/height from the BitmapMetadata or the
provided imageStream) and pass them into GetMetadataString(metadata, width,
height, DecodeTimeStamp(...)) or refactor callers to use the width/height-aware
path so the output includes the new dimensions token consistently (look for the
GetMetadataString overloads and DecodeTimeStamp usage to modify the correct
method).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3042eb52-1afa-4c47-9e64-818cc8b369ff

📥 Commits

Reviewing files that changed from the base of the PR and between ad4689c and 949df7f.

📒 Files selected for processing (2)
  • PhotoLocator/Metadata/ExifHandler.cs
  • PhotoLocator/VideoTransformCommands.cs

@meesoft meesoft merged commit 33762d6 into main Mar 6, 2026
5 checks passed
@meesoft meesoft deleted the features/ImageDimensions branch March 6, 2026 21:49
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