<p><a href="https://craftcms.stackexchange.com/a/1446/57">Christian is most likely correct.</a></p>

<p>Craft will try to use <a href="http://php.net/manual/en/book.imagick.php" rel="nofollow noreferrer">Imagick</a> 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 <a href="http://php.net/manual/en/book.image.php" rel="nofollow noreferrer">GD</a>, because it's installed on practically every host in the world.</p>

<p>Alternatively, you can manually tell Craft which image processing library to use with the <a href="http://buildwithcraft.com/docs/config-settings#imageDriver" rel="nofollow noreferrer">imageDriver</a> config setting.</p>

<p>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.</p>

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

CC BY-SA 3.0
2016-09-14T03:40:02.160Z
+1 for the "sanitize" mention... that's a critical piece of the puzzle that a lot of folks aren't aware of.
Lindsey D
CC BY-SA 3.0
2014-07-29T03:20:31.917Z
And thanks for the additional background and thorough explanation. This is super helpful info and much appreciated.
Brett Burwell
CC BY-SA 3.0
2014-07-28T02:59:16.623Z
2014-07-28T02:59:16.623Z
2017-04-13T12:50:59.930Z
Brad Bell
<p>Is Imagick installed on your server?</p>

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

CC BY-SA 3.0
2014-07-29T03:19:21.297Z
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
CC BY-SA 3.0
2014-07-31T09:17:01.040Z
Did you look into whether or not ICC is included (GD and Imagick), @Brett?
carlcs
CC BY-SA 3.0
2014-08-01T17:26:32.413Z
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
CC BY-SA 3.0
2014-07-27T22:34:01.347Z
2014-07-27T22:34:01.347Z
carlcs
<p>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. </p>

<p>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%. </p>

<p>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 <strong>not</strong> the same as using an image transform quality setting of 65 in Craft).</p>

<p>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. </p>

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

CC BY-SA 3.0
2014-07-27T22:01:07.233Z
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
<assets><image-transforms>
Using image transforms sometimes results in bloated file sizes.
# Using image transforms sometimes results in bloated file sizes.

(Asked by: username_0 on 2014-07-27)

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.

**Tags:** assets, image-transforms

> **Comments:**
> **username_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.  

---

## 2 answers

### Answer by username_4 on 2014-07-27. Score: 5 | Accepted answer

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

> **Comments:**
> **username_0**: 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.  
> **username_4**: Did you look into whether or not ICC is included (GD and Imagick), @Brett?  
> **username_0**: 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?  

---

### Answer by username_2 on 2014-07-28. Score: 3

[Christian is most likely correct.](https://craftcms.stackexchange.com/a/1446/57)

Craft will try to use [Imagick](http://php.net/manual/en/book.imagick.php) 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](http://php.net/manual/en/book.image.php), 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](http://buildwithcraft.com/docs/config-settings#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.

> **Comments:**
> **username_0**: And thanks for the additional background and thorough explanation. This is super helpful info and much appreciated.  
> **username_3**: +1 for the "sanitize" mention... that's a critical piece of the puzzle that a lot of folks aren't aware of.  

---

