Answers.Body: <p>The <code>upscaleImages</code> setting only cares about image <em>resolution</em> (pixel dimensions), not file size. If you set this to false, Craft will never create an image with larger dimensions than the base image. So if you upload a 2500px wide image, it won't upscale that to 2600px, even if you request that size in an image transform.</p>
  <p>The file size, however, depends on the amount of image compression. The size of the JPG file you're uploading depends on the quality settings it has been exported with, as well as any optimizations you may have applied to it. To create a transform, Craft has to decompress the image, convert it and then save it as a compressed image again. During this step, any compression / optimization you may have applied to the original JPG is lost in the generated image transform. So if you have, for example, exported the JPG from Photoshop with a low quality setting (e.g. ~60) and then run it through <a href="https://imageoptim.com/mac" rel="nofollow noreferrer">ImageOptim</a>, chances are that the generated transform will have a larger file size.</p>
  <p>You can optimize the generated transforms in a couple of ways:</p>
  <ul>
  <li>You can specify a <code>quality</code> setting between 0 and 100 as part of the transform. A lower setting will result in higher compression at the (potential) cost of image quality. If you don't specify a quality, Craft will use the <a href="https://craftcms.com/docs/4.x/config/config-settings.html#defaultimagequality" rel="nofollow noreferrer"><code>defaultImageQuality</code></a> general config setting. The default for this setting is <code>82</code>, which is a bit higher than you will need for most normal photos.</li>
  <li>You can also run image optimization tools as part of the image transformation process. <a href="https://plugins.craftcms.com/image-optimize" rel="nofollow noreferrer">ImageOptimize</a> is a plugin that does this for you.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-11T07:48:54.340Z
Answers.LastActivityDate: 2022-08-11T07:48:54.340Z
Answers.UserDisplayName: MoritzLost
Body: <p><strong>Question</strong></p>
  <p>Why is it that sometimes a transformed JPG is larger than its original when it is transformed using Craft image transforms even though in my <code>general.php</code> file I set <code>upscaleImages</code> to <code>false</code>?</p>
  <p><strong>Case details</strong></p>
  <p>I upload JPG images with a width of 2600px and run them through several image transforms, one of them transforming images to a width of 2600px as well. I do this just in case larger images are being uploaded. Since <code>upscaleImages</code> is set to <code>false</code>, I assumed that images that are already 2600px wide would be skipped, but they somehow still get duplicated into the folder with the other transforms. What's even worse: While the original JPG is 6.4mb, the transformed one is 7.2mb. A small difference, but this will add up quickly when uploading several hundred images.</p>
  <p>For testing purposes i also uploaded images i manually cropped to 2599px. They were not upscaled to 2600px (which is correct since I set <code>upscaleImages</code> to <code>false</code>) but they still got duplicated to a larger file size.</p>
  <p>I run Craft CMS 4.2.0.2 with ImageMagick.</p>
  
Tags: <assets><image-transforms><image>
Title: Transformed JPGs have larger file size than original
ThreadText: # Transformed JPGs have larger file size than original
  
  (Asked by: username_0 on 2022-08-10)
  
  **Question**
  
  Why is it that sometimes a transformed JPG is larger than its original when it is transformed using Craft image transforms even though in my `general.php` file I set `upscaleImages` to `false`?
  
  **Case details**
  
  I upload JPG images with a width of 2600px and run them through several image transforms, one of them transforming images to a width of 2600px as well. I do this just in case larger images are being uploaded. Since `upscaleImages` is set to `false`, I assumed that images that are already 2600px wide would be skipped, but they somehow still get duplicated into the folder with the other transforms. What's even worse: While the original JPG is 6.4mb, the transformed one is 7.2mb. A small difference, but this will add up quickly when uploading several hundred images.
  
  For testing purposes i also uploaded images i manually cropped to 2599px. They were not upscaled to 2600px (which is correct since I set `upscaleImages` to `false`) but they still got duplicated to a larger file size.
  
  I run Craft CMS 4.2.0.2 with ImageMagick.
  
  **Tags:** assets, image-transforms, image
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-08-11. Score: 2 | Accepted answer
  
  The `upscaleImages` setting only cares about image *resolution* (pixel dimensions), not file size. If you set this to false, Craft will never create an image with larger dimensions than the base image. So if you upload a 2500px wide image, it won't upscale that to 2600px, even if you request that size in an image transform.
  
  The file size, however, depends on the amount of image compression. The size of the JPG file you're uploading depends on the quality settings it has been exported with, as well as any optimizations you may have applied to it. To create a transform, Craft has to decompress the image, convert it and then save it as a compressed image again. During this step, any compression / optimization you may have applied to the original JPG is lost in the generated image transform. So if you have, for example, exported the JPG from Photoshop with a low quality setting (e.g. ~60) and then run it through [ImageOptim](https://imageoptim.com/mac), chances are that the generated transform will have a larger file size.
  
  You can optimize the generated transforms in a couple of ways:
  
  * You can specify a `quality` setting between 0 and 100 as part of the transform. A lower setting will result in higher compression at the (potential) cost of image quality. If you don't specify a quality, Craft will use the [`defaultImageQuality`](https://craftcms.com/docs/4.x/config/config-settings.html#defaultimagequality) general config setting. The default for this setting is `82`, which is a bit higher than you will need for most normal photos.
  * You can also run image optimization tools as part of the image transformation process. [ImageOptimize](https://plugins.craftcms.com/image-optimize) is a plugin that does this for you.
  
  
  ---
  
  