For a project I'm working on (master thesis), I need to figure out what is facebook's image compression algorithm.
The goal: to be able to mimic facebook's image compression locally (using python).
The images I use have the following exif: Image exif (Q = 90) After facebook compression, I have the following exif : Compressed image exif
Note: If the images I uploaded with the link seem unavailable, please refresh the page! :)
After searching for a while, I could not find a recent and clear answer to my question.
I tried to run the compressed image through ImageMagick's identify
. It tells me that it is a JPEG compression (DCT progressive + Huffman) with a quality of 85. But when I try to do my own compression using python, the result is not the same.
Here is my code:
from PIL import Image
img = Image.open('original.jpg')
img.save('output.jpg', optimize=True, quality=85, progressive=True)
Do you have any ideas or resources that could help me? I'm running out of ideas. Thank you!
identify
tool actually does; you might find it's not what you think it does: there's no canonical mapping of compression settings to percentages – it's all a bit of approximate / perceptive settings. It's quite possible Facebook doesn't even use classical JPEG for storage internally, but $\endgroup$