<p>This is likely to be a combination of factors.</p>

<p>Firstly; GD isn't all that great, so if you can get ImageMagik installed it's possible you'll get better results.</p>

<p>Secondly; This can depend on the image format too. PNGs for example are far more complicated to save optimised and it's unlikely that a PNG generated by a server is going to match the level of optimisations you can get locally through tools like TinyPNG and ImageOptim. PNGs have many more options for quality control than JPG's simple slider. Try to avoid transforms on anything other than JPGs.</p>

<p>Thirdly; check you're uploading an image that's larger than the crop you're creating. Craft has a horrible behaviour of blowing up images to match the crop. It's not really cropping, it's just taking any image and making it the size requested. That can mean 'cropped' images larger in filesize and dimension than the source.</p>

CC BY-SA 3.0
2015-11-16T12:03:20.043Z
Thanks Matt. In a [different answer](http://craftcms.stackexchange.com/a/1452/176) Brad Bell says that Imagick produces larger files size, so that’s confusing. But you are absolutely right, the problem seems to be with PNGs. JPG images are pretty much the same size on the server, though again a bit larger once transformed (by a third). None of the images are upsized with the transform. Having PNGs 2.5 times larger on the server is still not ideal though. Wonder if there’s anything else that can be done to bring that down.
Katrin
CC BY-SA 3.0
2015-11-16T12:21:44.953Z
Worth asking for clarification from the Craft devs; I had thought that ImageMagik had been tweaked to give smaller results in addition to better quality.

I would try to avoid PNGs as client-addable assets altogether. They're just not appropriate most of the time. I switch all Transforms to output JPGs. You could possibly try detecting the image type and conditionally applying transforms to avoid the issue and keep PNG Transparency (Assuming that's why you need PNG).
Matt Wilcox
CC BY-SA 3.0
2015-11-16T12:23:44.850Z
PS: if you're also getting larger JPG file sizes than what you're uploading as source, try dropping the quality of the transform.
Matt Wilcox
CC BY-SA 3.0
2015-11-16T12:34:54.597Z
JPGs seem pretty identical. Unfortunately, the site has images that contain some fine text, and using JPGs for those has resulted in the text looking too fuzzy. Also just spotted an image that is 75KB on local and is output at a whopping **470KB** on the site. So still keeping my fingers and toes crossed for some solution with PNGs...
Katrin
CC BY-SA 3.0
2015-11-18T11:38:33.797Z
Imagick/ImageMagick did the trick! Now the difference in size is only about 5% - so very minimal. Hooray!
Katrin
CC BY-SA 3.0
2015-11-16T11:49:57.423Z
2015-11-16T11:49:57.423Z
Matt Wilcox
<p>Image optimization has been <em>greatly</em> improved in Craft 2.5, for servers running ImageMagick. If you are OK with running beta software, install that and future uploads should be much smaller. <a href="http://buildwithcraft.com/beta" rel="nofollow">http://buildwithcraft.com/beta</a></p>

CC BY-SA 3.0
2015-11-17T12:17:02.103Z
Thanks Brandon. If I was to get ImageMagick now with v2.4.2723, would that help as well compared to GD?
Katrin
CC BY-SA 3.0
2015-11-17T12:32:33.373Z
@Katrin Probably somewhat (GD is just the worst). You'll also get some other improvements like animated GIF support.
Brandon Kelly
CC BY-SA 3.0
2015-11-17T12:49:21.053Z
Okidoki, I'll get it installed and have a look. Thank you.
Katrin
CC BY-SA 3.0
2015-11-17T12:04:54.350Z
2015-11-17T12:04:54.350Z
Brandon Kelly
<p>I am trying to bring image file sizes down as much as possible, but the images on the server turn out to be quite a bit larger than the same images I have saved locally.</p>

<p>For example, I have one local image that is 70KB. When I upload it into Assets it‘s 180KB. On the page itself it is being transformed like so:</p>

<pre><code>{% set imgSize = {
    mode: 'crop',
    width: 960,
    height: 450,
    quality: 75,
    position: 'center-center'
} %}
</code></pre>

<p>That transformed image on the page is then 208KB.</p>

<p>So rather than optimising file sizes as I thought it did, my set up is making the files 3 times larger.</p>

<p>I have checked the server with phpinfo, and I can't see Imagick installed, but GD v2.1.0 is.</p>

<p>What can I do to prevent the images from becoming larger?</p>

<assets><image-transforms>
Images much larger on server and page than the local version
# Images much larger on server and page than the local version

(Asked by: username_0 on 2015-11-16)

I am trying to bring image file sizes down as much as possible, but the images on the server turn out to be quite a bit larger than the same images I have saved locally.
For example, I have one local image that is 70KB. When I upload it into Assets it‘s 180KB. On the page itself it is being transformed like so:
{% set imgSize = {
    mode: 'crop',
    width: 960,
    height: 450,
    quality: 75,
    position: 'center-center'
} %}

That transformed image on the page is then 208KB.
So rather than optimising file sizes as I thought it did, my set up is making the files 3 times larger.
I have checked the server with phpinfo, and I can't see Imagick installed, but GD v2.1.0 is.
What can I do to prevent the images from becoming larger?

**Tags:** assets, image-transforms

---

## 2 answers

### Answer by username_1 on 2015-11-16. Score: 3 | Accepted answer

This is likely to be a combination of factors.

Firstly; GD isn't all that great, so if you can get ImageMagik installed it's possible you'll get better results.

Secondly; This can depend on the image format too. PNGs for example are far more complicated to save optimised and it's unlikely that a PNG generated by a server is going to match the level of optimisations you can get locally through tools like TinyPNG and ImageOptim. PNGs have many more options for quality control than JPG's simple slider. Try to avoid transforms on anything other than JPGs.

Thirdly; check you're uploading an image that's larger than the crop you're creating. Craft has a horrible behaviour of blowing up images to match the crop. It's not really cropping, it's just taking any image and making it the size requested. That can mean 'cropped' images larger in filesize and dimension than the source.

> **Comments:**
> **username_0**: Thanks Matt. In a [different answer](http://craftcms.stackexchange.com/a/1452/176) Brad Bell says that Imagick produces larger files size, so that’s confusing. But you are absolutely right, the problem seems to be with PNGs. JPG images are pretty much the same size on the server, though again a bit larger once transformed (by a third). None of the images are upsized with the transform. Having PNGs 2.5 times larger on the server is still not ideal though. Wonder if there’s anything else that can be done to bring that down.  
> **username_1**: Worth asking for clarification from the Craft devs; I had thought that ImageMagik had been tweaked to give smaller results in addition to better quality.  I would try to avoid PNGs as client-addable assets altogether. They're just not appropriate most of the time. I switch all Transforms to output JPGs. You could possibly try detecting the image type and conditionally applying transforms to avoid the issue and keep PNG Transparency (Assuming that's why you need PNG).  
> **username_1**: PS: if you're also getting larger JPG file sizes than what you're uploading as source, try dropping the quality of the transform.  
> **username_0**: JPGs seem pretty identical. Unfortunately, the site has images that contain some fine text, and using JPGs for those has resulted in the text looking too fuzzy. Also just spotted an image that is 75KB on local and is output at a whopping **470KB** on the site. So still keeping my fingers and toes crossed for some solution with PNGs...  
> **username_0**: Imagick/ImageMagick did the trick! Now the difference in size is only about 5% - so very minimal. Hooray!  

---

### Answer by username_2 on 2015-11-17. Score: 2

Image optimization has been *greatly* improved in Craft 2.5, for servers running ImageMagick. If you are OK with running beta software, install that and future uploads should be much smaller. <http://buildwithcraft.com/beta>

> **Comments:**
> **username_0**: Thanks Brandon. If I was to get ImageMagick now with v2.4.2723, would that help as well compared to GD?  
> **username_2**: @Katrin Probably somewhat (GD is just the worst). You'll also get some other improvements like animated GIF support.  
> **username_0**: Okidoki, I'll get it installed and have a look. Thank you.  

---

