Skip to content

Conversation

@stesee
Copy link

@stesee stesee commented Nov 30, 2025

Support to compare image metadata (exif, ...) added:

var imageCompare= new ImageCompare(compareMetadata: true);
var result = imageCompare.ImagesAreEqual("image.jpg","imageWithStrippedMetadata.jpg");
Console.Writeline(result);
# False

Introduces metadata comparison to SkiaSharpCompare, allowing image comparisons to include differences in metadata as well as pixel data. Adds new classes for metadata extraction and comparison, updates interfaces and result DTOs, and extends ImageCompare and SkiaSharpCompare APIs to support the new functionality. Includes new tests and test data for metadata comparison.
Introduces a new SkiaSharpCompare.Cli project with programmatic and console entry points for file and directory image comparison. Adds SkiaSharpCompare.Cli.Tests with NUnit-based tests for CLI logic. Updates the GitHub Actions workflow to build, publish, and upload CLI artifacts for multiple platforms, and includes CLI artifacts in release assets. Updates the solution file to include the new projects.
Introduces a --meta option to the CLI for displaying image metadata. Enhances MetadataExtractorAdapter with improved documentation, normalization, and duplicate key handling. Also adds null checks in CalcDiff and updates ImageCompare constructor documentation.
Updated file name extraction in CliRunner to filter out nulls before casting to string, preventing possible exceptions. In SkiaSharpCompare.cs, moved and reordered the CalcDiffInternal method without functional changes.
Enhanced the metadata comparison test to log actual and expected metadata differences using a new FormatMetadata helper. This aids in diagnosing test failures by providing detailed output in test run logs.
Artifacts are now uploaded and named per OS using matrix.os, and downloads attach all CLI artifacts regardless of OS. This improves release creation by ensuring all relevant artifacts are included.
Added [SetCulture("en-US")] to ensure consistent formatting in test assertions. Updated expected metadata values to use periods as decimal separators and periods in time stamps, matching en-US culture.
Renamed imageWithMetadataA.jpg to imageWithoutGpsMetadata.jpg and imageWithMetadataB.jpg to imageWithGpsMetadata.jpg for clarity. Updated all references in SkiaSharpCompareMetaDataTests.cs and TestFiles.cs to use the new names, and adjusted file paths in TestFiles.cs to use './' prefix for consistency.
Updated the file paths for colorShift1 and colorShift2 to use the correct case, ensuring compatibility with case-sensitive file systems.
Copilot AI review requested due to automatic review settings November 30, 2025 08:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for comparing image metadata (EXIF, GPS, etc.) in addition to pixel-level comparison. The implementation integrates the MetadataExtractor library to extract and compare metadata from images. The PR also includes significant refactoring of test files to centralize test file path constants and introduces a new CLI project for command-line image comparison.

Key Changes:

  • Added metadata comparison capability via new compareMetadata parameter in comparison APIs
  • Introduced MetadataExtractorAdapter and MetadataComparer classes for metadata handling
  • Created a new CLI project (SkiaSharpCompare.Cli) with directory and file comparison support
  • Refactored test files to use centralized TestFiles.cs for test data paths
  • Updated package versions and added MetadataExtractor dependency

Reviewed changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
SkiaSharpCompare/MetadataExtractorAdapter.cs New adapter class for extracting metadata from images using MetadataExtractor library
SkiaSharpCompare/MetadataComparer.cs New internal class implementing metadata comparison logic
SkiaSharpCompare/SkiaSharpCompare.cs Added compareMetadata parameter to static comparison methods with early-exit logic
SkiaSharpCompare/ImageCompare.cs Added CompareMetadata property and integrated metadata comparison into instance methods
SkiaSharpCompare/ICompareResult.cs Added MetadataDifferences property to expose metadata comparison results
SkiaSharpCompare/CompareResult.cs Updated to include metadata differences using primary constructor syntax
SkiaSharpCompare/CompareResultWithMetadata.cs New wrapper class for combining pixel and metadata comparison results
SkiaSharpCompareTestNunit/TestFiles.cs New centralized test file constants to eliminate duplication
SkiaSharpCompareTestNunit/SkiaSharpStaticCompareTests.cs Refactored to use TestFiles constants and renamed parameters for clarity
SkiaSharpCompareTestNunit/SkiaSharpCompareTests.cs Refactored to use TestFiles constants
SkiaSharpCompareTestNunit/SkiaSharpCompareMetaDataTests.cs New comprehensive tests for metadata comparison feature
SkiaSharpCompare.Cli/Program.cs New CLI entry point supporting file/directory comparison and metadata display
SkiaSharpCompare.Cli/CliRunner.cs New helper class providing programmatic API for CLI operations
SkiaSharpCompare.Cli.Tests/SkiaSharpCompareCliTests.cs New tests for CLI functionality
.github/workflows/dotnet.yml Updated to build and publish CLI artifacts for multiple platforms

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/// <param name="PathPic2"></param>
/// <returns></returns>
public SKBitmap CalcDiffMaskImage(string absolutePathPic1, string absolutePathPic2)
public SKBitmap CalcDiffMaskImage(string PathPic1, string PathPic2)
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

Inconsistent parameter naming: Parameter PathPic1 uses PascalCase, which is inconsistent with C# naming conventions for parameters (should be camelCase: pathPic1). Note that the method body uses this in PascalCase on line 181, which should also be corrected.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI commented Nov 30, 2025

@stesee I've opened a new pull request, #76, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Nov 30, 2025

@stesee I've opened a new pull request, #77, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Nov 30, 2025

@stesee I've opened a new pull request, #78, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Nov 30, 2025

@stesee I've opened a new pull request, #79, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Nov 30, 2025

@stesee I've opened a new pull request, #80, to work on those changes. Once the pull request is ready, I'll request review from you.

Introduced a DecodeStream helper to centralize SKBitmap decoding from streams, improving reliability and code reuse. Updated ImageCompare and SkiaSharpCompare to use this helper and ensure streams are reset as needed. Added new NUnit tests for metadata comparison using SKBitmap and Stream inputs, and renamed SkiaSharpCompareMetaDataTests to SkiaSharpCompareMetaData_PathTests for clarity.
Renamed method parameters in ImageCompare.cs and SkiaSharpCompare.cs to use more descriptive and consistent names (e.g., image1, image2, pathImage1, pathImage2) instead of ambiguous names like pic1, actual, or expected. This improves code readability and aligns parameter naming across the codebase.
Added 'github-actions[bot]' and 'copilot[bot]' to the CLA workflow allowlist to ensure these bots are not blocked by the CLA check.

contributor-assistant/github-action#169
Introduces SkiaSharpCompareCliIntegrationTests to verify CLI execution and output. Also removes unused usings from SkiaSharpCompareCliTests.cs and Program.cs for improved code clarity.
Replaced explicit addition with the '+=' operator for absoluteError and sum variables to improve code readability and consistency.
Refactored CompareResultWithMetadata to use a C# primary constructor and auto-property initializers. Split CalcDiff into CalcDiff and CalcDiffInternal to separate mask-based and non-mask-based image comparison logic, and moved DecodeStream to a more appropriate location. Improved code clarity and maintainability by reorganizing methods and updating parameter handling.
Copy link

Copilot AI commented Dec 6, 2025

@stesee I've opened a new pull request, #82, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits December 6, 2025 13:25
Co-authored-by: stesee <168659+stesee@users.noreply.github.com>
Co-authored-by: stesee <168659+stesee@users.noreply.github.com>
Zip CLI artifacts directory for release attachments
@github-actions
Copy link

github-actions bot commented Dec 6, 2025


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@stesee stesee merged commit c15c8b5 into main Dec 6, 2025
5 of 6 checks passed
@stesee stesee deleted the DiffMetadata branch December 6, 2025 14:47
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants