# Changing max\_image\_size\_kb

**URL:** https://meta.discourse.org/t/changing-max-image-size-kb/247420
**Category:** Support
**Tags:** uploads, s3
**Created:** [December 2, 2022, 1:25am UTC](https://meta.discourse.org/t/changing-max-image-size-kb/247420 "2022-12-02T01:25:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fearlessfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fearlessfrog/32/119653_2.png) [@fearlessfrog](https://meta.discourse.org/u/fearlessfrog)
#### Post date: [December 2, 2022, 1:25am UTC](https://meta.discourse.org/t/changing-max-image-size-kb/247420/1 "2022-12-02T01:25:31Z")

</div>

We’re thinking of changing our setting for max image size kb, as we we started out with it quite high and need to save some S3 costs. I wanted to check my understanding before hitting the button.

I think this setting on setting only gets applied to new uploads? Is there a way to resize existing uploads to use the new max value (e.g. resize the originals of anything over the max)? I’m was sort of hoping something like `bundle exec rake posts:rebake` would do it (maybe)?

If that wouldn’t work, what’s the best approach here? An older build of discourse had a Rails [script/downsize\_uploads.rb](https://github.com/discourse/discourse/blob/4c89f7f88165c28bfc8ecb15a3be7346985d384e/script/downsize_uploads.rb) but I think that’s gone from github now? Is there anything else or is my best bet just to use that code on a more recent Discourse - I think it uses megapixel as the constraint rather than kb?

Thanks for any help/advice.

---

<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: [December 2, 2022, 2:08am UTC](https://meta.discourse.org/t/changing-max-image-size-kb/247420/2 "2022-12-02T02:08:46Z")

</div>

> [@fearlessfrog](#):
>
> An older build of discourse had a Rails [script/downsize\_uploads.rb](https://github.com/discourse/discourse/blob/4c89f7f88165c28bfc8ecb15a3be7346985d384e/script/downsize_uploads.rb) but I think that’s gone from github now?

It was converted into `rake uploads:downsize`. Be sure to glance over [the script code](https://github.com/discourse/discourse/blob/main/lib/tasks/uploads.rake#L1095) as this is a destructive action.

> [@fearlessfrog](#):
>
> We’re thinking of changing our setting for max image size kb

Nowadays the client side image compression should yield enough saving to keep image uploads in check. Do you have it enabled?

---

<div class="post-metadata">

### Author: ![fearlessfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fearlessfrog/32/119653_2.png) [@fearlessfrog](https://meta.discourse.org/u/fearlessfrog)
#### Post date: [December 2, 2022, 3:06am UTC](https://meta.discourse.org/t/changing-max-image-size-kb/247420/3 "2022-12-02T03:06:53Z")

</div>

We have client compression working and it does really well at keeping the image sizes down since it was introduced. We’ve been live with Discourse since about May 2015, and probably never changed the max image size before so that rask task looks ideal - thank you!

---

<div class="post-metadata">

### Author: ![fearlessfrog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fearlessfrog/32/119653_2.png) [@fearlessfrog](https://meta.discourse.org/u/fearlessfrog)
#### Post date: [December 5, 2022, 9:45pm UTC](https://meta.discourse.org/t/changing-max-image-size-kb/247420/4 "2022-12-05T21:45:00Z")

</div>

> [@Falco](#):
>
> Be sure to glance over [the script code](https://github.com/discourse/discourse/blob/main/lib/tasks/uploads.rake#L1095) as this is a destructive action.

Apologies in that I can’t sign the CLA due to my work, so without a PR wanted to pass on that..

> <https://github.com/discourse/discourse/blob/1d42cc94a2c74633178d4e75560368d89576f2aa/lib/tasks/uploads.rake#L1100>

..needs to be ARGV[1], otherwise it’s always using 500\_000 regardless of what’s passed in. Thanks again for the pointer to the right task, all files resized and working great. ❤

---

<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: [December 5, 2022, 9:48pm UTC](https://meta.discourse.org/t/changing-max-image-size-kb/247420/5 "2022-12-05T21:48:22Z")

</div>

> [@fearlessfrog](#):
>
> [discourse/lib/tasks/uploads.rake at 1d42cc94a2c74633178d4e75560368d89576f2aa · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/1d42cc94a2c74633178d4e75560368d89576f2aa/lib/tasks/uploads.rake#L1100)
> 
> …needs to be ARGV[1], otherwise it’s always using 500\_000 regardless of what’s passed in.

cc @cvx, do we need to update that?

---

<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: [January 4, 2023, 9:48pm UTC](https://meta.discourse.org/t/changing-max-image-size-kb/247420/6 "2023-01-04T21:48:56Z")

</div>

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