# Help me understand image compression

**URL:** https://meta.discourse.org/t/help-me-understand-image-compression/274297
**Category:** Support
**Created:** [August 8, 2023, 3:32am UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297 "2023-08-08T03:32:12Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Brandon007](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@Brandon007](https://meta.discourse.org/u/Brandon007)
#### Post date: [August 8, 2023, 3:32am UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/1 "2023-08-08T03:32:12Z")

</div>

I’m not quite sure I understand image compression in Discourse. Straighten me out.

- I uploaded a 2392x884 214kb image and the resolution stayed the same.
- I uploaded a 3200x1800 1.7mb image and the resolution scaled down to the `composer media optimization image resize dimensions threshold` setting.

With the setting at 1280 wide, I expected all images to be scaled down to that width. However, it appears the `composer media optimization image bytes optimization threshold` sets the precedent.

- My first image was under 524kb, so it wasn’t altered.
- The second image was over 524kb, so it **was** altered.

If I follow correctly, is there a way to reduce all uploaded files to 1280 wide?

Here are my settings to confirm:

`max image size kb` = 4096

 ![compression](https://global.discourse-cdn.com/meta/original/4X/1/a/d/1ad14ce868f864e53e74a80931db0e4aec785aaf.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 8, 2023, 3:35am UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/2 "2023-08-08T03:35:37Z")

</div>

> [@Brandon007](#):
>
> appears the `composer media optimization image bytes optimization threshold` sets the precedent.

Maybe set that threshold very low?

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [August 8, 2023, 7:57am UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/3 "2023-08-08T07:57:17Z")

</div>

Because topic is named in very general way I don’t start new topic 😙 but what does `client-side optimization` mean in practice - an OS of device will make its mind if it will do or not something? But that will lead to the situation where a giga big image must transfer to a client before its size will change to decent scale, or am I totally lost now?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [August 8, 2023, 8:10am UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/4 "2023-08-08T08:10:48Z")

</div>

> [@Brandon007](#):
>
> However, it appears the `composer media optimization image bytes optimization threshold` sets the precedent.

After testing, it is correct 🙂  
I believe @pfaffman’s solution is the way to go to achieve what you want.

> [@Jagster](#):
>
> but what does `client-side optimization` mean in practice

Long explanation: [Faster (and smaller) uploads in Discourse with Rust, WebAssembly and MozJPEG](https://blog.discourse.org/2021/07/faster-user-uploads-on-discourse-with-rust-webassembly-and-mozjpeg/)  
Short explanation: large images are resized/recompressed on your device (via javascript) before they are sent to Discourse.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [August 8, 2023, 8:15am UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/5 "2023-08-08T08:15:26Z")

</div>

> [@Canapin](#):
>
> before they are sent to Discourse

Right, it works to that direction. Well, that is much more smarter way than optimization to other direction 🤦‍♂️

Thanks.

---

<div class="post-metadata">

### Author: ![Brandon007](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@Brandon007](https://meta.discourse.org/u/Brandon007)
#### Post date: [August 8, 2023, 12:46pm UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/6 "2023-08-08T12:46:14Z")

</div>

> [@Brandon007](#):
>
> composer media optimization image bytes optimization threshold

I did try that last night before posting and that does seem to be the key.

Here’s the deal:

`composer media optimization image bytes optimization threshold`

- 524288 (default) setting = Good quality image, 1920px.
- 200000 setting = Degraded image, since it drops resolution from 1920 to 1280.

So this morning, on my desktop, I took the same image (2392px), resized it to 1280px and it’s degraded a bit as well. So the degradation I can’t get around. It’s a product of dropping the resolution from 2392px to 1280px. It did reduce the image size by four times though.

> **Note:**.HEIC photos don’t play by the same rules. A 4032px .HEIC was reduced to 2016px. So I don’t know how that setting was applied.

All in all, I think I get it, after a little trial and error. I think I’ll use the default settings, I really like the extra crispness of a 1920px photo over the 1280px.

Hopefully, this helps someone else out.

> **Edit:** I dropped `composer media optimization image bytes optimization threshold` from the default of `524288` to `200000`. I noticed, uploading a basic .png file at 1220px @ 414kb only resulted in a file size of 406kb. By reducing the setting above to `200000`, the file size was reduced from 414kb to 201kb. The resolution was unchanged.
> 
> So I don’t know **what else is being triggered with that setting** , but clearly something else to further reduce the image size.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 8, 2023, 6:17pm UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/7 "2023-08-08T18:17:11Z")

</div>

> [@Brandon007](#):
>
> I’m not quite sure I understand image compression in Discourse. Straighten me out.

I find the diagram at the [blog post](https://blog.discourse.org/2021/07/faster-user-uploads-on-discourse-with-rust-webassembly-and-mozjpeg/) helpful:

 ![](https://global.discourse-cdn.com/meta/original/4X/d/7/e/d7e4816d540d2bf73ba16f8a2672ef24dfa9f587.jpeg)

X → `composer media optimization image bytes optimization threshold`  
Y → `composer media optimization image resize dimensions threshold`  
Z → `composer media optimization image resize width target`

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [November 9, 2025, 2:23pm UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/8 "2025-11-09T14:23:04Z")

</div>

> [@Falco](#):
>
> Y → `composer media optimization image resize dimensions threshold`  
> Z → `composer media optimization image resize width target`

I’m afraid I must be dumb for not quite understanding this part when looking at the settings’ definitions:

**composer\_media\_optimization\_image\_dimensions\_resize\_threshold:** default 1920  
Minimum image width to trigger client-side resize

**composer\_media\_optimization\_image\_dimensions\_resize\_target:** default 1920  
Images wider than `composer_media_optimization_image_dimensions_resize_threshold` will be resized to this width.  
Must be ≥ that threshold.

This part specifically:

> Must be ≥ that threshold.

Shouldn’t it be ≤ instead? I don’t understand why it would resize to a higher width value than the threshold 🤔

Also, in the same setting’s description, the first setting is misnamed:

> `composer_media_optimization_image_dimensions_resize_threshold`

The right name is “Composer media optimization image resize dimensions threshold” (“resize dimensions”, not “dimensions resize”).

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [December 9, 2025, 2:23pm UTC](https://meta.discourse.org/t/help-me-understand-image-compression/274297/9 "2025-12-09T14:23:54Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
