Is there a way to reduce image file size on upload?

PumpinIron

Well-known member
In this modern day we live in where images are getting bigger and bigger, I was wondering if such an option (or add-on?) exists where an image size is reduced on upload?

I've got my max image upload size set at 12 MB. That's quite big by all means, however, people are constantly trying to upload photos from their phone that are often times 20 MB or more. They are of course met with file size error messages.

Is there a way to resize an image on upload so that members don't encounter these errors?
 
@AndyB helped me set this up. In Options - Attachments, I have max file size 12,000 kb, maximum attachment image dimensions 800 x 600, but there was also something set up in public_html to remove the file size restriction - you'd better ask him about that as I can't remember. My site is very image heavy and never had an issue (even before converting to image optimisation and webp).
 
I'm a bit late to the party but can anybody explain to me exactly how this works? I'm trying to get my head around it.

You can set a maximum attachment size both in pixel dimensions (I have mine set to 2560 h and w) and KB (mine is set to 6144KB).

As I understand it, enabling "optimise images" does 2 things:
  1. Allows resizing on the client size before upload
  2. Converts all image uploads to .webp format
I'm wondering how these 2 factors interact. Is this interpretation correct?
  1. If I upload an image that exceeds the KB limit that will just fail immediately
  2. If the image is a valid KB size, then it will resize the image to fit the pixel dimensions limit
I'm also curious about how the client resizing works. Is it JS based? Does it ever fail? Might some users have it disabled? Is there a server side fallback if so? Stuff like that.

I haven't been able to find any documentation on this beyond this post by @Chris D. If there is any, would you be able to point me in the right direction?

It's a really really nice feature to have auto resizing. And one I wish were enabled on more forums that I use. Image size errors are so annoying and it just screws the experience up compared to SM platforms who seem to handle it without any issues.

Cheers
 
  1. If I upload an image that exceeds the KB limit that will just fail immediately
  2. If the image is a valid KB size, then it will resize the image to fit the pixel dimensions limit
This is correct.

Is it JS based?
Yes
Does it ever fail?
Probably only in the same ways a server side resize might
Might some users have it disabled?
Not really. Edge case would be a very old browser (or having JS disabled, very rare) but that's not really something we need to worry about. That user will hit bigger problems before they even get to uploading images.
Is there a server side fallback if so?
The server would attempt to resize to the max dimensions if the client doesn't do it for some reason.
 
Actually, this is correct. The upload is attempted, even if it exceeds that file size. It will only be rejected if it's too big after a resize is attempted.
 
Back
Top Bottom