Search code examples
pythoncomputer-visionpython-imaging-libraryjpeg

Why is image saved by PIL have different md5 sum compared with the original image


assume I have a image pic.jpg. I read the image and then save it.

from PIL import Image
im = Image.open('pic.jpg')
im.save('pic1.jpg', 'jpeg')

The md5 sum of the two pictures are different:

$ md5sum pic.jpg
3191102e44fa5ebbb2aa52e042066dad
$ md5sum pic1.jpg
a6b17e3af3ff66715a2326db33548d11

Do I still have the original image if I read and then save with PIL?


Solution

  • After some comparision it seems like PIL recompress the image (all binary data are not the same), also headers change (for me an Adobe header, title and author was here but disapear).
    If you would do some comparision you may can do :

    xxd pic.jpg > pic.hex
    xxd pic1.jpg > pic1.hex
    diff pic.hex pic1.hex