If I have a .gif and a .png file, can I compare them to see if they represent the same image?

For example, let's say I have a .jpeg and I convert it to .gif and .png

x.jpeg ---> x.gif
       ---> x.png

if I compare the .gif and .png is there a way to determine they have similar image data? how easy is it do that? would it be a pixel by pixel comparison?

  • 3
    I don't really understand. I mean if you export a jpg to a gif and a png, of course they are going to have "similar image data" - they all represent the same initial image. The difference will be in how the data is stored due to the format. And I'm not certain delving into different formats and how they store data is a "graphic design" question.
    – Scott
    Jun 21, 2022 at 21:37
  • GIFs are always in Indexed colour, but PNG can be in Indexed (PNG8), RGB (PNG24), or RGBa (PNG32). You could directly compare a GIF with an Indexed colour PNG, but an RGB or RGBa PNG will have different pixel values from a GIF, even if the images are visually similar. So it really depends on the format.
    – Billy Kerr
    Jun 21, 2022 at 23:12
  • 3
    ImageMagick includes a compare utility. It has various options that you might find useful, depending on what you're actually trying to do.
    – r3mainer
    Jun 22, 2022 at 9:38

4 Answers 4

  1. Open both images on your photo editing software. Let's say it is Gimp.

  2. Copy the GIF image on the clipboard and paste it over the PNG (Not the other way around)*

  3. Change the blending mode to difference.

  4. Any different pixels will be highlighted there. If you can barely see an image you could adjust the levels to increase the difference.

Here is an example I made some time ago using that method.

*Not the other way around is because the GIF image is most likely an indexed color file. If you paste a 24-bit image over it, the new layer will be remapped to the colors and bit depth of the GIF file.

When pasting an indexed image over a 24 bit one, the colors of the indexed image will simply be used as they are.


JPEG uses a non-RGB color model, GIF supports color-map images only, while PNG can support true color images.

So the first challenge is that PNG does not store more colors than the GIF when converting the same image. Basically I'm expecting differences to exist in most cases.

How to see those difference is explained in https://graphicdesign.stackexchange.com/a/157576/165458 nicely.


If you need to do this regularly, and are willing to spend a few bucks, you could try the excellent software "Beyond Compare" which will display both pictures next to each other, show a third image with minor differences tinted blue and bigger differences tinted red, allow you to see the RGB values of corresponding pixels, and also compare metadata.

I'm not affiliated with them except being a satisfied customer for more than 10 years.

Here's an example - original picture left, opened and saved with worse quality on the right, and the difference below:

enter image description here


If you know your way around some basic Python, this is a rather easy task with OpenCV.

Load in both images, convert them into 3 RGB pixelmaps each, and then subtract them from eachother. You can then combine them again with a logical OR. You will end up with a heatmap that shows how different each pixel is from the other.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.