-
-
Notifications
You must be signed in to change notification settings - Fork 0
Diff metadata #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diff metadata #75
Conversation
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.
There was a problem hiding this 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
compareMetadataparameter 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.
SkiaSharpCompare/ImageCompare.cs
Outdated
| /// <param name="PathPic2"></param> | ||
| /// <returns></returns> | ||
| public SKBitmap CalcDiffMaskImage(string absolutePathPic1, string absolutePathPic2) | ||
| public SKBitmap CalcDiffMaskImage(string PathPic1, string PathPic2) |
Copilot
AI
Nov 30, 2025
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
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
|
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. |
Support to compare image metadata (exif, ...) added: