concretecms / concrete5-legacy

Legacy repository for concrete5
http://www.concrete5.org
559 stars 323 forks source link

Fix ImageMagick not applying defined compression quality #1920

Closed hamsterbacke23 closed 6 months ago

hamsterbacke23 commented 9 years ago

I had the problem that with ImageMagick it never uses the image compression rate I defined in the config/site.php. Seems to be a problem for this guy as well: http://www.concrete5.org/community/forums/customizing_c5/jpeg-image-file-sizes-too-large-imagemagick-may-be-the-cause./

I've noticed that $image->getCompression() just returns 0 all the time, a problem noted by someone here as well: http://php.net/manual/en/imagick.getcompression.php

So the solution would be, to test for jpegs from the file extension instead, and use the Method "setImageCompressionQuality" instead of "setCompressionQuality" which actually seems to work...

I was checking the image quality via identify -verbose http://urloftheimage.jpg | grep -i quality

JohntheFish commented 9 years ago

if checking for jpg/jpeg extension, some sites will also have enabled uppercase and mixed case variations of the extension that need to be handled by this.

hamsterbacke23 commented 9 years ago

exif_imagetype() might be a good idea... wont be able to test for the next 3 weeks myself though. http://stackoverflow.com/questions/1141227/check-if-the-image-is-a-jpeg

Remo commented 9 years ago

@hamsterbacke23 I don't think we can rely on that as it's part of an extension. Using that if available and then check the file extension with proper lower- / uppercase conversion sounds good to me. Any objections to that?

hamsterbacke23 commented 9 years ago

Nope should be ok