# Image upload max size and further resizing regression issue

**URL:** https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755
**Category:** Feature
**Created:** [4월 11, 2017, 3:15오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755 "2017-04-11T03:15:38Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [4월 11, 2017, 3:15오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/1 "2017-04-11T03:15:38Z")

</div>

Continuing the discussion from [Resize images after uploading](https://meta.discourse.org/t/resize-images-after-uploading/30575/7):

> [@Resize images after uploading](https://meta.discourse.org/t/resize-images-after-uploading/30575/7):
>
> This is now done. We’ll accept images of up to 10MB and then downsize them to the maximum allowed image size 🐆

Not sure if this has been discussed already and whether it has been considered a bug or an expected behavior.

The issue is, my setup won’t accept images up to 10MB. It will only accept images up to the size configured in the `max_image_size_kb` setting.

So if I set it as small as 860KB, that becomes the maximum size accepted while uploading the image.

What I expect instead is that images up to 10MB are accepted, and then resized to the maximum size configured in the setting.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [4월 11, 2017, 3:26오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/2 "2017-04-11T03:26:58Z")

</div>

That is not the meaning of the setting.

Hmm let’s clarify with @zogstrip first.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [4월 11, 2017, 5:40오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/3 "2017-04-11T05:40:18Z")

</div>

> [@meglio](#):
>
> What I expect instead is that images up to 10MB are accepted, and then resized to the maximum size configured in the setting.

Well, if you upload a 8MB image, there might be a chance we won’t be able to automatically resize it down to 860KB in the limited amount of time we allow for size reduction.

We limit this process since it is very CPU intensive and can be used as a DDoS vector.

What’s more, there is no way to predict the size of an image before actually resizing it.  
This is what makes this hard…

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [4월 11, 2017, 6:22오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/4 "2017-04-11T06:22:15Z")

</div>

Sure, all the reasoning makes a lot of sense.

But the error message is confusing and does not explain what is going on.

I’m trying to upload an image which is much less than 10MB, and the error message says “sorry the max you can upload is 860KB”. Makes no sense for end users.

If it can’t be resized in time, an error message should say something like that and help the user to understand what to do next.

The only thing they can try after reading the existing message is to downsize the image to 860kb, why they actually don’t need to.

Makes sense?

So, I suppose there is an issue, it is either of the two:

1. Which error messages are used in which scenarios
2. Uploading limitation issue?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [4월 11, 2017, 6:28오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/5 "2017-04-11T06:28:11Z")

</div>

Are you uploading a very large png? If so do not do that; switch to jpg.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [4월 11, 2017, 6:39오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/6 "2017-04-11T06:39:09Z")

</div>

Sometimes it’s just an image from clipboard that I insert directly via Ctrl+V.

Despite I can educate myself to save images in JPG and then upload them, there is still that issue of an error message that confuses and makes little sense.

If it is said that an images up to 10MB can be uploaded (and we say that to our users as well), why can’t they upload an image of e.g. 2MB or 3MB or 4MB? It is less than 50% of the allowed size, yet that error pops up that says “sorry up to 864KB” only. It is this error messaging that I’m trying to get fixed.

I mean, it seems as if the error message does not reflect the actual issue and does not help user solve the issue but to dramatically sizedown their images.

If it was unable to size the image down, it should say something about it — i.e. your image is fine in size but we couldn’t resize it, try resizing it to half of its size before uploading etc - something like that.

> [@zogstrip](#):
>
> Well, if you upload a 8MB image, there might be a chance we won’t be able to automatically resize it down to 860KB in the limited amount of time we allow for size reduction.

Btw:

- can we make this time limit configurable?
- can we queue image resizing which failed and display the image thumbnail in the meantime? (the server might be idle at night)
- just as an idea, using [image number limit per TL](https://meta.discourse.org/t/limit-number-of-images-uploaded-by-user-per-day-wil-tl-multipliers/57690) can eliminate DDoS vector.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [4월 11, 2017, 8:11오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/7 "2017-04-11T08:11:58Z")

</div>

> [@meglio](#):
>
> If it was unable to size the image down, it should say something about it — i.e. your image is fine in size but we couldn’t resize it, try resizing it to half of its size before uploading etc - something like that.

I agree we can do better on that front.

> [@meglio](#):
>
> can we make this time limit configurable?

It isn’t possible right now but isn’t hard to do.

> [@meglio](#):
>
> can we queue image resizing which failed and display the image thumbnail in the meantime? (the server might be idle at night)

I’ll think about it.

* * *

_EDIT:_

- **client-side:** we could add a warning when the image size is larger than the maximum allowed (_letting the user know that the final image will be downsized_)
- **server-side:** use the thumbnail in the post but run a background job that will try (harder) to downsize the original image

[@team](https://meta.discourse.org/groups/team) what do you think?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [4월 11, 2017, 8:48오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/8 "2017-04-11T08:48:20Z")

</div>

I don’t really see what the problem is – if the image is large, _always_ try JPG first.

PNG on large images is _incredibly_ risky. Just **start with JPG on large dimension images** and if you get good results, don’t go any farther.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [4월 11, 2017, 9:03오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/9 "2017-04-11T09:03:18Z")

</div>

> [@codinghorror](#):
>
> I don’t really see what the problem is

Here is how I see it — the problems are:

1. The error messages are misleading and can be improved to make more sense
2. While it is said that images up to 10MB can be uploaded, it does not work like that
3. CPU could be used more intense (queued) to downsize an image after the actual upload happens, instead of refusing image upload which is smaller than 10MB.

The focus in this report is on that the functionality does not correspond to the claims.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [4월 11, 2017, 9:15오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/10 "2017-04-11T09:15:03Z")

</div>

> [@meglio](#):
>
> So if I set it as small as 860KB, that becomes the maximum size accepted while uploading the image.

This is an _insanely_ small value. I think 1024kb is quite low for a maximum image file size, much less.. anything smaller than that.

I think the real issue here is, you should allow larger images if you users want to upload images. Make room, buy more server storage space, etc. That or **disallow uploading images altogether and force them to post images to imgur (or similar) first**.

---

<div class="post-metadata">

### Author: ![SimeonGriggs](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@SimeonGriggs](https://meta.discourse.org/u/SimeonGriggs)
#### Post date: [7월 15, 2017, 9:18오후 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/11 "2017-07-15T21:18:20Z")

</div>

> [@codinghorror](#):
>
> That or disallow uploading images altogether and force them to post images to imgur (or similar) first

I have an issue with this though. Many image hosting services don’t have upload size limits. So a person can upload a 100mb GIF, which then loads on our forum and burns through the users mobile data caps.

I’d like the image size restrictions to apply to even linked images. Maybe with a ‘click to load’ button replacing it.

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [8월 27, 2017, 1:31오후 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/12 "2017-08-27T13:31:26Z")

</div>

> [@codinghorror](#):
>
> I don’t really see what the problem is – if the image is large, always try JPG first.

The problem is, not all users even know the _difference_ between JPEG and PNG, let along being able to resize and convert them before uploading.

Also, that are a lot of cases when a screen-shot is copied to the clipboard in PNG format (for example, FireFox’s new screen-shot feature). People are just gonna Ctrl-V to paste that photo into a message and fire away. They are not gonna take the time to convert and downsize.

Can there be a background low-priority job running that automatically resize these uploaded images to a particular maximum size?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [8월 28, 2017, 3:16오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/13 "2017-08-28T03:16:38Z")

</div>

That is already the way it works.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 2, 2018, 11:46오후 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/14 "2018-05-02T23:46:49Z")

</div>

A post was split to a new topic: [Changing image width/height manually does not always work!](https://meta.discourse.org/t/changing-image-width-height-manually-does-not-always-work/86649)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 2, 2018, 11:50오후 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/15 "2018-05-02T23:50:50Z")

</div>

To me the OP looks like a feature request.

The request here is to add a second site setting.

Then we would have:

- Maximum allowed upload size
- Maximum allowed image size.

That way … you can allow 6MB uploads but force all images to 300kb by dropping quality.

Technically I think this is doable and probably an option we should offer.

The alternative of resizing on the client side is just a bit too flakey to get working properly.

@codinghorror thoughts?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 2, 2018, 11:51오후 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/16 "2018-05-02T23:51:24Z")

</div>

Pretty sure this already exists via site settings, cc @zogstrip @techAPJ

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [5월 2, 2018, 11:54오후 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/17 "2018-05-02T23:54:14Z")

</div>

Yup, we already do that.

We don’t have a `maximum allowed upload size` site setting though. It’s only limited via NGINX.

And we also have another site setting to help downsize images: `max image megapixels`.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 3, 2018, 12:02오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/18 "2018-05-03T00:02:54Z")

</div>

Yeah I think this is all covered now.

We try downsizing 3 times prior to creating the upload.

@meglio can we close this?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 3, 2018, 12:45오전 UTC](https://meta.discourse.org/t/image-upload-max-size-and-further-resizing-regression-issue/60755/19 "2018-05-03T00:45:44Z")

</div>


