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

Comments

Projects
None yet
3 participants
@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

This comment has been minimized.

Copy link
Owner

emcconville commented Mar 10, 2016

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

This comment has been minimized.

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 added a commit that referenced this issue Mar 15, 2019

@emcconville emcconville added this to the 0.5.2 milestone Mar 15, 2019

@emcconville

This comment has been minimized.

Copy link
Owner

emcconville commented Mar 15, 2019

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
You can’t perform that action at this time.