Skip to content

Tiff image JPEG compression up to 3x original image disk size #7001

@GiovanniNova

Description

@GiovanniNova

I have been using this library for a while and although it works extremely well and is much faster than say, OpenCV, I noticed that it has some issues with compression.

When converting an image from JPEG to TIF they can end up with over 3x their original disk size, this woudn't be an issue for 1 or 2 images but we have over 4.000 images.

Sample code:

from PIL import Image

with Image.open('original.jpg') as image:
	image.save('pillow - 50.jpg', optimize=True, compression='jpeg', quality=50)
	image.save('pillow - 50.tif', optimize=True, compression='jpeg', quality=50)
	
	image.save('pillow - 75.jpg', optimize=True, compression='jpeg', quality=75)	
	image.save('pillow - 75.tif', optimize=True, compression='jpeg', quality=75)

Original 89%: 3.352 kb
Photoshop 9/12 (75%): 3.417 kb
Pillow 50% .JPG: 1.175 kb
Pillow 50% .TIF: 3.828 kb
Pillow 75% .JPG: 2.320 kb
Pillow 75% .TIF: 7.206 kb

original.zip
result.zip

  • Windows 10 x64
  • Python 3.9.6
  • Pillow 9.4.0
  • LibTiff 3.8.2-1 (features.check('libtiff') returns True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions