I am using PIL to rotate some images, and I noticed that the output file is much smaller, so I tried a test: Do nothing to the file, except save the exif info (because I know that PIL Image will by default not save the exif info). So here is my test code:
from PIL import Image
test = Image.open('my_image_file.jpg')
holdexif = test.info["exif"]
test.save('my_saved_image_file.jpg',"jpeg",exif=holdexif)
When I do the above my_saved_image_file.jpg is significantly smaller (441 KB) than the original my_image_file (1.83 MB). Why is that? What is missing?
When I look at various properties of both files, they appear to be identical. Both are 56 inches x 27 inches, both are 72 Pixels per inch, both are 4032 x 1960 pixels. I am by no means an expert when it comes to image files. Based on these things that I have examined (size, resolution, and the appearance of the images) the files appear to me to be the same. From what I can see/understand, only the file size on disk is different. What else should I be looking at? What else may be different?
I also tried the quality= kwarg in the save:
test.save('my_saved_image_file.jpg',"jpeg",exif=holdexif,quality=95)
which gave me a file (1.73 MB) almost as large as the original (1.83 MB). But I have no idea what is different to account for the larger size (and I don't understand what makes the "quality" better; the images appear the same to me). I am trying to understand what exactly is different between the two files, so that I can make a decision. Perhaps the smaller size is perfectly fine for my purposes.
PILs IMAGE is doing the compression. you can check github.com/python-pillow/Pillow/blob/master/src/PIL/… heredifferencetab,