A partial archive of meta.discourse.org as of Tuesday July 18, 2017.

Image upload max size and further resizing regression issue

meglio

Continuing the discussion from Resize images after uploading:

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.

codinghorror

That is not the meaning of the setting.

Hmm let's clarify with @zogstrip first.

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.

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

meglio

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?
codinghorror

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

meglio

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.

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 can eliminate DDoS vector.
zogstrip

I agree we can do better on that front.

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

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 what do you think?

codinghorror

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.

meglio

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.

codinghorror

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.

SimeonGriggs

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.