How to compare 2 images to check if it is identical. The easiest way is to compare pixel by pixel of the 2 images.
In my example, I am using Python Pillow to compare. To install it in macOS, just run these 2 lines
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow
For other OS, you can refer to their official site at https://pillow.readthedocs.io/en/stable/installation.html
The source code of my function
WebP
- I downloaded a 360x360 WebP image from Google PlayStore and named it a.webp
- Duplicate a.webp to b.webp
- Edit 1 pixel in b.webp in GIMP
PNG
- Converted a.webp to a.png using ImageMagick
- Duplicate a.png to b.png
- Edit 1 pixel in b.png
convert a.webp a.png
BMP
- Converted a.webp to a.bmp using ImageMagick
- Duplicate a.bmp to b.bmp
- Edit 1 pixel in b.bmp
convert a.webp a.bmp
GIF
- Converted a.webp to a.gif using ImageMagick
- Duplicate a.gif to b.gif
- Edit 1 pixel in b.gif
convert a.webp a.gif
JPG
- Converted a.webp to a.jpg using ImageMagick
- Duplicate a.jpg to b.jpg
- Edit 1 pixel in b.jpg
- Save as 100% quality
convert a.webp a.jpg
Conclusion
My favorite file type is PNG although GIF has a smaller file size because GIF looks grainy after the conversion with default settings.
Works with
- GIF, PNG, BMP
Does NOT work with
- WebP, JPG
Related articles
Jigsaw Search In Image (version 1)
Needle In Haystack Search (version 2)