0

I have 2 .png images loaded in memory (they exist as 'bytes' objects) and I need to tell if they are equal or not. I tried to do a checksum, but it doesn't work, since png image format contains some non-pixel data that makes 2 graphically identical images get different checksums. I just need to compare these images and tell if they are equal or not, I don't need to find similarities or something like this. I will appreciate any help.

Tihran
  • 106
  • 4

1 Answers1

0

You can read your 2 images as numpy arrays with OpenCv s.t.

import cv2
image1 = cv2.imread("image1.png")
image2 = cv2.imread("image2.png")
if (image1 == image2):
   print("same images")
else:
   print("not same images")
Jacques75
  • 81
  • 3
  • To be honest, I was trying to find the answer without the big dependency such as OpenCV, but this is correct to I am marking it – Tihran Mar 01 '21 at 20:07