Some notes on comparing/contrasting/diffing image files.
- ImageMagick – pixel-by-pixel image comparison
- https://imagemagick.org
- Install:
- macOS:
brew install imagemagick
- macOS:
- Basic comparison:
-
magick compare original.jpg altered.jpg -metric RMSE diff.png
-metric RMSE
→ Root Mean Square Error (prints numerical difference)diff.png
highlights pixel differences (black = no change; bright colors = differences)
-
- Normalizing first avoids false positives from orientation/colorspace:
-
magick original.jpg -auto-orient -colorspace sRGB -alpha off PNG24:orig_norm.png magick altered.jpg -auto-orient -colorspace sRGB -alpha off PNG24:alt_norm.png magick compare -metric RMSE orig_norm.png alt_norm.png diff.png
-
- Other useful metrics:
-
magick compare -metric PSNR orig_norm.png alt_norm.png null: # Peak Signal-to-Noise Ratio magick compare -metric DSSIM orig_norm.png alt_norm.png null: # Structural dissimilarity
- RMSE: 0 = identical; 0.001–0.01 ≈ tiny difference
- PSNR: >40 dB ≈ visually indistinguishable
- DSSIM: 0 = identical; ≤0.01 ≈ negligible difference
-
- Change highlight colors for easier viewing:
-
magick compare orig_norm.png alt_norm.png -metric RMSE \ -highlight-color yellow -lowlight-color black diff.png
-
- Visual toggling (flicker test)
- Side-by-side montage:
-
magick montage orig_norm.png alt_norm.png -tile 2x1 -geometry +0+0 side_by_side.png
-
- Or use an image viewer to rapidly flip between the two.
- Side-by-side montage:
- Perceptual metrics
- SSIMULACRA2 and Butteraugli are perceptual quality metrics from Google/Cloudinary, designed to align more with human vision than raw RMSE/PSNR.
- https://github.com/myint/perceptualdiff
-
perceptualdiff
-
A program that compares two images using a perceptually based image metric.
- Install:
- macOS:
brew install perceptualdiff
- macOS:
- Basic comparison:
-
perceptualdiff orig_norm.png alt_norm.png
- Exit code
0
if perceptually identical,1
if differences exceed threshold.
-
- With visual diff output and verbose stats:
-
perceptualdiff orig_norm.png alt_norm.png -verbose -output diff.png
-
- Adjusting sensitivity (higher threshold = less sensitive to small differences):
-
perceptualdiff orig_norm.png alt_norm.png -threshold 100 -verbose -output diff.png
-
-
- GUI tools
- Beyond Compare – has an image compare mode with overlay/difference views.