Skip to content

File format conversion#81

Merged
meesoft merged 3 commits into
mainfrom
features/FileConverter
May 11, 2026
Merged

File format conversion#81
meesoft merged 3 commits into
mainfrom
features/FileConverter

Conversation

@meesoft
Copy link
Copy Markdown
Owner

@meesoft meesoft commented May 10, 2026

Summary by CodeRabbit

  • New Features

    • Added image format conversion functionality supporting JPEG, TIFF, PNG, JPEG XR, and BMP formats with a new menu option.
  • Refactor

    • Refactored internal image transformation architecture to support broader file format operations and improve metadata handling across formats.

Review Change Stack

@meesoft meesoft changed the title Features/file converter File format conversion May 10, 2026
@meesoft meesoft marked this pull request as ready for review May 10, 2026 19:41
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

Walkthrough

This PR unifies image transformation commands under a broader ImageTransformCommands class (renamed from JpegTransformCommands), adds a new multi-format file conversion feature, simplifies the Photoshop loader API by removing transformation parameters, normalizes file extension handling to lowercase, and updates all dependent code—ViewModels, UI bindings, tests—accordingly.

Changes

Image Format Conversion Feature & Command Surface Unification

Layer / File(s) Summary
API Contract: Photoshop Loader Simplification
PhotoLocator/PictureFileFormats/PhotoshopFileFormatHandler.cs
LoadFromStream overload signature narrows from (stream, rotation, maxWidth, preservePixelFormat, ct) to (stream, ct), removing transformation and sizing parameters.
Command Class Refactoring & Conversion
PhotoLocator/ImageTransformCommands.cs
JpegTransformCommands renamed to ImageTransformCommands; new ConvertFileFormatCommand added with folder selection, file conflict handling, batch image conversion with metadata, and progress tracking.
File Format Infrastructure
PhotoLocator/PictureFileFormats/GeneralFileFormatHandler.cs, PhotoLocator/Metadata/ExifHandler.cs
File extension matching switched to lowercase comparison; EXIF metadata transfer mode (setValue) changed from 1 to 2 for WmpBitmapEncoder.
ViewModel Integration
PhotoLocator/MainViewModel.cs
Property JpegTransformCommands renamed to ImageTransformCommands; CropCommand wired to ImageTransformCommands.CropSelectedItemAsync for non-video selections.
UI Bindings & Menus
PhotoLocator/MainWindow.xaml
All command references updated to ImageTransformCommands; window input bindings for Ctrl+L (contrast) and Ctrl+R (astro); new "Convert to" submenu with format options (JPEG, TIFF, PNG, JPEG XR, BMP).
Call Site Updates
PhotoLocator/PictureItemViewModel.cs
Photoshop preview loader updated to call simplified LoadFromStream(fileStream, ct) overload.
Tests & Cleanup
PhotoLocatorTest/PictureFileFormats/PhotoshopFileFormatHandlerTest.cs, PhotoLocatorTest/Metadata/ExifHandlerTest.cs, PhotoLocator/BitmapOperations/IIRSmoothOperation.cs
All Photoshop tests updated to use simplified loader API; EXIF test refactored to compare dynamic metadata strings; using directives reordered in IIRSmoothOperation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • meesoft/PhotoLocator#21: Prior work that added CropSelectedItemAsync to JpegTransformCommands and updated ViewModel handling; this PR renames that class to ImageTransformCommands and updates all references.
  • meesoft/PhotoLocator#28: Modifies the same PictureItemViewModelPhotoshopFileFormatHandler callsite; both PRs change the LoadFromStream signature and update the call site.
  • meesoft/PhotoLocator#80: Prior changes to JpegTransformCommands (adding AstroCommandParameter and keybindings); this PR renames that class and updates all UI bindings accordingly.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'File format conversion' directly describes the primary feature added in this PR—a new ConvertFileFormatCommand that enables converting images between multiple formats (JPEG, TIFF, PNG, JPEG XR, BMP).
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch features/FileConverter

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
Copy Markdown
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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
PhotoLocator/ImageTransformCommands.cs (1)

228-234: ⚖️ Poor tradeoff

Consider clearer feedback for partial conversion.

When the user cancels the overwrite-all prompt (line 232), the loop breaks immediately. Files processed before the break remain converted, but there's no explicit indication to the user that the operation completed partially. The progress bar will reflect this, but a summary message might improve clarity.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PhotoLocator/ImageTransformCommands.cs` around lines 228 - 234, The loop that
checks overwriteAll when encountering an existing targetFileName (the
MessageBox.Show branch) can exit early leaving a partial conversion with no
explicit summary; modify the branch inside the loop that currently breaks on
cancel so that before breaking it records the partial outcome (e.g., counts of
files converted vs skipped) and after the loop displays a concise summary
MessageBox to the user indicating the operation was partially completed and how
many files were processed/left; update variables used in the loop (overwriteAll,
any processedCount/ skippedCount) and show the summary after the loop exits
normally or early so users get clear feedback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PhotoLocator/ImageTransformCommands.cs`:
- Around line 226-227: The two branches build inconsistent filenames: when
targetIsSourceDir the code uses item.GetProcessedFileName() (which may include a
postfix) but when moving to targetDir it uses item.Name; make the base filename
consistent by always using GetProcessedFileName() (e.g., compute baseName =
Path.GetFileNameWithoutExtension(item.GetProcessedFileName())) and then set
targetFileName by combining targetDir with baseName + "." + targetType (or use
Path.ChangeExtension on the processed filename when targetDir == sourceDir),
ensuring both branches derive names from GetProcessedFileName() so postfix
behavior is consistent.
- Around line 204-243: The MessageBox.Show call inside the
ConvertFileFormatCommand's RunProcessWithProgressBarAsync lambda is running on a
background thread; marshal it to the UI thread by invoking
Application.Current.Dispatcher.Invoke (or BeginInvoke) when showing the confirm
overwrite dialog and capturing its result into a local variable before using it
to break/continue; update the code around the MessageBox.Show invocation so the
dispatcher call returns the MessageBoxResult and use that result to set
overwriteAll or break the loop (keep references to ConvertFileFormatCommand,
RunProcessWithProgressBarAsync, and MessageBox.Show when locating the change).

---

Nitpick comments:
In `@PhotoLocator/ImageTransformCommands.cs`:
- Around line 228-234: The loop that checks overwriteAll when encountering an
existing targetFileName (the MessageBox.Show branch) can exit early leaving a
partial conversion with no explicit summary; modify the branch inside the loop
that currently breaks on cancel so that before breaking it records the partial
outcome (e.g., counts of files converted vs skipped) and after the loop displays
a concise summary MessageBox to the user indicating the operation was partially
completed and how many files were processed/left; update variables used in the
loop (overwriteAll, any processedCount/ skippedCount) and show the summary after
the loop exits normally or early so users get clear feedback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7aa183fb-6a10-4943-b93f-cfcd7d56e515

📥 Commits

Reviewing files that changed from the base of the PR and between 2867859 and 41f4744.

📒 Files selected for processing (10)
  • PhotoLocator/BitmapOperations/IIRSmoothOperation.cs
  • PhotoLocator/ImageTransformCommands.cs
  • PhotoLocator/MainViewModel.cs
  • PhotoLocator/MainWindow.xaml
  • PhotoLocator/Metadata/ExifHandler.cs
  • PhotoLocator/PictureFileFormats/GeneralFileFormatHandler.cs
  • PhotoLocator/PictureFileFormats/PhotoshopFileFormatHandler.cs
  • PhotoLocator/PictureItemViewModel.cs
  • PhotoLocatorTest/Metadata/ExifHandlerTest.cs
  • PhotoLocatorTest/PictureFileFormats/PhotoshopFileFormatHandlerTest.cs

Comment thread PhotoLocator/ImageTransformCommands.cs
Comment thread PhotoLocator/ImageTransformCommands.cs
@meesoft meesoft merged commit 0f29f25 into main May 11, 2026
5 checks passed
@meesoft meesoft deleted the features/FileConverter branch May 11, 2026 19:09
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