Changing max_image_size_kb

AI-generated summary

The discussion revolves around changing the max_image_size_kb setting in Discourse to reduce S3 costs. fearlessfrog seeks confirmation on whether the change only affects new uploads and if existing images can be resized to meet the new limit. Falco clarifies that the rake uploads:downsize task can be used for this purpose, noting it’s a destructive operation. fearlessfrog confirms they have client-side compression enabled and successfully use the task. fearlessfrog also points out a bug in the script where the target size is hardcoded to 500,000 unless ARGV[1] is used, prompting Falco to tag a developer for a fix.

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

It was converted into rake uploads:downsize. Be sure to glance over the script code as this is a destructive action.

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

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!

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

..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. :heart:

cc @cvx, do we need to update that?