Resizing images after upload settings

Hi All,
totally confused after reading threads here about image resizing etc.

I’ve set “client_max_body_size” to 102400 in admin->settings-files to allow uploading from cellphones.
But I cannot for the life of me figure out where to set image resizing.

I’ve read some thread:


but just cannot get the image to resize.

Help ?


related question:
Are all uploads sent to /shared/uploads/default/original/1X/ ?

Could I use a convert -resize $WIDTH image.jpg to resize ? perhaps ?

Not sure I understand :thinking:… What are you trying to achieve exactly?

There is no such setting as “client_max_body_size” in Admin > Settings. That’s a NGINX setting.

Sorry. In my haste I posted the wrong thing
I meant max image size kb

I’m trying to scale images from 3400 px wide to something more reasonable

1 Like

Discourse will automatically create thumbnails for you (we call that process lightboxing). Is that not working?

Ues the thumbnails is working. But the thumbnail Links to the original file that is huge (by default from most phones nowadays)

1 Like

Oh, you meant resizing the original uploaded image?

The only way to do it right now is via the “max image size kb” site setting.
Whenever a user uploads an image that is larger than this setting, we’ll try to downsize it to fit the setting.

Since it’s CPU/time consuming, we’re only trying to downsize (halving the dimensions) the image 3 times.

If you want another behavior, you’ll have to write a plugin.

1 Like

Ok cool.
So back to my confusion.
Where do i set this site wide setting?

Like I said, change “max image size kb” to a lower value.

1 Like

Right … so i set the Max upload in nginx. And the resized size in discourse ?

Pretty much yeah. For nginx, you’ll need to change it via the app.yaml file in order to survive container rebuilds.

as far as I know, you should resize images yourself (in your desktop), and discourse will not resize huge images for you.

the setting limits the size of the image one is allowed to upload.

1 Like

You’re right. Any indication I got from meta is that max image size kb is the maximum allowed uploaded image size. Over this size and the image upload will simply be rejected.

It has been said that Discourse will scale down very large images in the background; how large is very large, and how much to scale down has always remained a mystery.

Now, @zogstrip, does it mean that max image size kb is actually the trigger level for the scale down itself? In other words, if I have:

  • Max upload size in app.yaml = 20MB
  • max image size kb = 1MB

My original understanding is that uploading any image above 1MB will be rejected.

Now @zogstrip is saying that as long as the image is no larger than 20MB it can still be uploaded. But then in the background it will be scaled down (because >1MB), half-dimensioned three times, essentially making it 1/64 of the size?

1 Like

It’s not a mystery if it’s written in plain text :wink:

Ok, so here’s what happens when a user uploads an image

  • NGINX accepts the image up to its “client_max_body_size” setting (defaults to 10MB, can be overwritten in app.yml)
  • Then, we’ll convert large PNG/BMPs to JPEG to keep the filesize at bay
  • Then, we’ll halve (up to 3 times) the uploaded image until it’s lower than the “max image size kb” site setting
  • If the image is still larger, then we’ll reject it :boom:
  • Then, go on with the upload process (fix orientation, crop, optimize…)

Ah. Clear as mud now. :wink:

So it is not a background job that resizes after-all… It gets done at the time of the upload.

I think the description of the setting needs some serious rewriting:

“The maximum image upload size in kB. This must be configured in nginx (client_max_body_size) / apache or proxy as well.”

I don’t think it is accurate AT ALL.


Sure, what text do you think would make more sense there?

Something like:

Automatically scale down uploaded images to smaller than this size. Images too large to be resized will be rejected. Note: Do not set larger than upload size limit configured in nginx (client_max_body_size) / apache or proxy.

What do you think @zogstrip?

This might be a bit too verbose for a site setting description but I :heart: the idea.

#pr-welcome :wink: