2

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.

1
  • 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
    Commented Jul 27, 2014 at 22:01

2 Answers 2

5

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!).

3
  • 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. Commented Jul 29, 2014 at 3:19
  • Did you look into whether or not ICC is included (GD and Imagick), @Brett?
    – carlcs
    Commented Jul 31, 2014 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? Commented Aug 1, 2014 at 17:26
3

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.

2
  • And thanks for the additional background and thorough explanation. This is super helpful info and much appreciated. Commented Jul 29, 2014 at 3:20
  • +1 for the "sanitize" mention... that's a critical piece of the puzzle that a lot of folks aren't aware of.
    – Lindsey D
    Commented Sep 14, 2016 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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