Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image compression? #278

Closed
rlam3 opened this issue Mar 9, 2016 · 3 comments
Closed

Image compression? #278

rlam3 opened this issue Mar 9, 2016 · 3 comments
Milestone

Comments

@rlam3
Copy link

rlam3 commented Mar 9, 2016

Is there a way to compress the image size but not resolution?

Similar to http://stackoverflow.com/questions/21920028/how-does-python-pil-and-pillow-compress-pictures

@emcconville
Copy link
Owner

You can use wand.image.BaseImage.compression_quality to match PIL's quality, and wand.image.BaseImage.resolution for dpi.

Example...

from wand.image import Image

with Image(filename="input.jpg") as image:
    image.compression_quality = 90
    image.resolution = (300, 300)
    image.save(filename="output.jpg")

@xmedeko
Copy link

xmedeko commented Nov 1, 2018

The compression_quality does not work for me for PNG image:

with Image(filename='input.png') as img:
    img.compression_quality = 95
    img.save(filename=self.tmp_filename('output.png'))

The result is same does not matter which compression_quality I set. From commandline convert input.png -quality 95 output.png it works - I see different file size.

Update: solution is to use: MagickSetCompressionQuality (ImageMagick releases after 6.8.7-5) instead of MagickSetImageCompressionQuality (ImageMagick releases before 6.8.7-5), see:

@emcconville
Copy link
Owner

Setting Image.compression_quality now sets both image & image info properties on MagickWand instances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants