Images are still too big -- how to compress further?


Images that are uploaded from smartphones are commonly over 4MB in size (my max upload size is set to 5MB). I just took one of these images are dumped it into ImageOptim and the size dropped to under 800KB. I can’t tell the difference when viewing the pics.

Is there any way to have something like this done on my forum automagically?

(charles) #2

4.2MB and compressed to 759KB without making quality suffer?

That’s impressive since even Google can’t even do that


It’s not impressive, but that’s besides the point. I’m simply asking if there’s a solution or some kind of work around. I tried lowering the allowable upload max image size, but then users can’t upload images from mobile devices at all (“your file is too big, yadda yadda”).

4MB image sizes are simply unnecessary.

(Anton) #4

I’m very interested as well!

I though though that images get resized/compressed after initial upload, so you can even allow e.g. 10MB uploads, but limit max image width/height dimensions in your Settings.

(Jeff Atwood) #5

There is some support for this @zogstrip can elaborate as he has time.


Hey @zogstrip have you had time to look into this?

(OG) #7

There is definitely demand for further compression / pixel size limiting after upload.

Imho it should be allowed to upload big files but optimize / downsize them on the server after upload based on parameters from admin config.

Specifically for mobile uploads it would be beneficial to downsample them while keeping high quality / low compression (then to keep high res and compress photo with loss). Phone lenses are very low quality and even that there is high megapixel (usually it is just marketing) chip it doesn’t have any more pixel information than reasonably downsized photo.

(Anton) #8

Yes. For example, for our non-commercial community it tends to become vital. Every cent counts when no one is sponsoring… How much money we spend on the server, it mostly depend on how much space our current $20/mo DigitalOcean instance still have.

(OG) #9

Exactly… from my experience fast access drives (15k SAS HDD or SSD) have always been biggest factor to server operating cost.

(Régis Hanol) #10

FYI: I recently re-worked our upload pipeline, which includes auto-converting large PNGs into (very) small JPEGs. You can fine tune the quality of the JPEGs with the “png to jpg quality” site setting.

(Jeff Atwood) #11

The paint point here was very large uploaded PNGs which had absolutely no business being lossless PNGs, when they could be lossy JPGs at 1/5 or less the size. For small images (1280x720 or less) it does not matter so much, but get to 1080p++ and the cost becomes … extreme.

1,651,936 Screenshot_2017-04-16-21-23-50.png
1,701,243 Screenshot_2017-04-16-21-23-54.png

  323,789 Screenshot_2017-04-16-21-23-50.jpg
  288,995 Screenshot_2017-04-16-21-23-54.jpg

This also has super bad ramifications for PNG optimizers which take n2 or worse time as the image gets larger… here’s pngout.exe behavior by image size:

s1 → 2.1s
s2 → 2.2s

1280x720 (720p)
s1 → 3.7s
s2 → 3.2s

1920x1080 (1080p)
s1 → 32s
s2 → 33s

3840x2160 (4k)
s1 → 57s
s2 → 42s


Yeah, larger res PNG’s are way bigger than JPEG’s. I am considering removing PNG’s from the approved files list; do any smartphones use PNG as the native capture format?

(Jeff Atwood) #13

You shouldn’t need to worry, latest version of Discourse handles this perfectly and seamlessly. If Bad Users upload giant PNGs we auto-force-convert them as needed.

(Stephen Chung) #14

BTW, how large is considered giant?

(Jeff Atwood) #15

Look in your site settings for the image related settings.

(Stephen Chung) #16

Sorry to be a pest, but the only image relevant settings I can find are max image size and max image megapixels.

Are you saying that pngs larger than max image megapixels will be converted to jpegs?

(Jeff Atwood) #17

This is something you can pretty easily test for yourself on – give it a shot!