Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

I'm in the process of setting up Asset image transforms for my site and was playing with the quality setting to find the right balance between file size vs. output image quality.

As part of the testing process I was outputting matching images at the same final transform size in Photoshop at various levels of "Save for Web..." quality. I was surprised to see that the images Craft was generating were consistently larger in file size than the images Photoshop was generating with approximately the same final visual quality. Typically the difference was anywhere from 20-40%.

It feels important to note that I realize that Craft's image transform quality settings don't equate to Photoshop's "Save for Web..." quality settings (i.e. using a quality setting of 65 in Photoshop is not the same as using an image transform quality setting of 65 in Craft).

I tested a variety of image types at a variety of transform and quality settings and found the results to be roughly the same in every scenario.

I'm curious if anyone else has seen / noticed this issue and if there might be a fix.

share|improve this question
    
I've had roughly the same experience with the image quality coming out of Asset Transforms. For most images I've found it extremely difficult to get the same quality out of a transform for close to the same file size. In many cases, this results in a transformed image being a lower visual quality than the original (which was exported using a "Save for Web"), even at the same dimensions and a "higher" quality level. –  cmal Jul 27 at 22:01

2 Answers 2

up vote 3 down vote accepted

Is Imagick installed on your server?

If not, Craft uses GD as a "fallback". Chances are that transforms with GD lead to poorer image quality and longer calculation times. I'm not sure about ICC profiles, but I think they only get included using Imagick (photos can look really bad if profile is missing unexpectedly!).

share|improve this answer
    
This is definitely what it was. Thanks for the response. Getting Imagick in place immediately brought the optimization levels up to what I would typically expect to see. –  Brett Burwell Jul 29 at 3:19
    
Did you look into whether or not ICC is included (GD and Imagick), @Brett? –  carlcs Jul 31 at 9:17
    
Thanks for the followup. I didn't, as things seem to be working well now. Would having ICC included help optimize things even further? And if so, how would I go about checking to see if it was included? –  Brett Burwell Aug 1 at 17:26

Christian is most likely correct.

Craft will try to use Imagick if it is available, because it's infinitely more flexible and produces better quality images, but that is at the expense of larger file sizes. Craft will fallback to GD, because it's installed on practically every host in the world.

Alternatively, you can manually tell Craft which image processing library to use with the imageDriver config setting.

When an image is first uploaded, Craft will "sanitize" the image for any malicious code by re-saving the image out to a new file. It jumps through some pretty significant to ensure that the sanitized image is as close to possible as the originally uploaded image in both quality and file size, which usually explains the differences people see in file sizes.

However, this process does not happen during an image transform (for obvious reasons), which leads us back to the image processing extension in use.

share|improve this answer
    
And thanks for the additional background and thorough explanation. This is super helpful info and much appreciated. –  Brett Burwell Jul 29 at 3:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.