Skip to content

Comments

fix: simplify image comparison logic by removing MIME type check#461

Merged
k1LoW merged 1 commit intomainfrom
check-distance-all-images
Oct 29, 2025
Merged

fix: simplify image comparison logic by removing MIME type check#461
k1LoW merged 1 commit intomainfrom
check-distance-all-images

Conversation

@k1LoW
Copy link
Owner

@k1LoW k1LoW commented Oct 29, 2025

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 Image struct, specifically in the Equivalent method. 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:

  • The perceptual hashing comparison is now applied to all image types, rather than being restricted to JPEGs, making the equivalence check more robust against Google Slides compression for a wider range of images.
  • Removed the unnecessary conditional block that limited perceptual hashing to JPEG images, simplifying the code and ensuring consistent behavior.

Since we discovered that Google Slides compresses not only JPEGs but also large images, we will perform the pHash comparison on all images.
@k1LoW k1LoW requested a review from Copilot October 29, 2025 10:41
@k1LoW k1LoW self-assigned this Oct 29, 2025
@k1LoW k1LoW added enhancement New feature or request integration-test labels Oct 29, 2025
@github-actions
Copy link
Contributor

Code Metrics Report

main (1dd2029) #461 (dd78b91) +/-
Coverage 32.3% 32.3% -0.1%
Code to Test Ratio 1:0.8 1:0.8 +0.0
Test Execution Time 10s 11s +1s
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%)

Files Coverage +/- Status
image.go 66.8% -0.2% modified

Reported by octocov

Copy link
Contributor

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

@k1LoW k1LoW merged commit 282e25f into main Oct 29, 2025
9 checks passed
@k1LoW k1LoW deleted the check-distance-all-images branch October 29, 2025 10:57
@github-actions github-actions bot mentioned this pull request Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request integration-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant