fix: simplify image comparison logic by removing MIME type check#461
Merged
fix: simplify image comparison logic by removing MIME type check#461
Conversation
Since we discovered that Google Slides compresses not only JPEGs but also large images, we will perform the pHash comparison on all images.
Contributor
Code Metrics Report
Details | | main (1dd2029) | #461 (dd78b91) | +/- |
|---------------------|----------------|----------------|-------|
- | Coverage | 32.3% | 32.3% | -0.1% |
| Files | 30 | 30 | 0 |
| Lines | 3191 | 3190 | -1 |
- | Covered | 1032 | 1031 | -1 |
+ | Code to Test Ratio | 1:0.8 | 1:0.8 | +0.0 |
| Code | 6552 | 6550 | -2 |
| Test | 5796 | 5796 | 0 |
- | Test Execution Time | 10s | 11s | +1s |Code coverage of files in pull request scope (67.0% → 66.8%)
Reported by octocov |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR extends perceptual hash comparison to all image types (PNG, GIF, JPEG), not just JPEG images. Previously, only JPEG images used perceptual hashing for equivalence comparison to handle Google Slides compression. The change recognizes that Google Slides compresses all image types, especially large images.
- Removed MIME type check that restricted perceptual hashing to JPEG only
- Updated comment to clarify that all image types can be compressed by Google Slides
- Applied perceptual hash comparison uniformly across PNG, GIF, and JPEG formats
Comments suppressed due to low confidence (1)
image.go:43
- The comment on line 43 states 'Perceptual hash for JPEG images' but the code now uses perceptual hashing for all image types (PNG, GIF, JPEG). Update the comment to reflect this broader usage, e.g., 'Perceptual hash for image comparison'.
pHash *goimagehash.ImageHash // Perceptual hash for JPEG images
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since we discovered that Google Slides compresses not only JPEGs but also large images, we will perform the pHash comparison on all images.
This pull request refines the logic for comparing image equivalence in the
Imagestruct, specifically in theEquivalentmethod. The main improvement is broadening the use of perceptual hashing to compare all images, not just JPEGs, to better account for compression artifacts introduced by Google Slides.Image equivalence logic improvements: