Specifying maximum uploaded (not thumbnail) image width and height

Hi, I have a relatively new discourse site up, http://growingfruit.org. Everything has been going great, in a way too great as I am getting lots of image uploads and at the current rate it could end up maxing out my hosting plan in a few years. I was having complaints from novice users not able to upload larger images so I upped that limit to 10MB. But, I am now seeing 100MB per week of uploads and the site is still young.

I don’t need a short-term solution to this problem but I would sleep better if I knew I could just compress the existing images on the server in /var/discourse/shared/standalone/uploads/default/nnn/ directories and not have anything break. It would be even better if I could resize them. I tried compressing one image and it still loaded fine and nothing seemed to break, but if there is metadata stored in the database about the images there could be some problem down the road perhaps.

Scott

1 Like

I would not recommend altering images on the server. While it won’t break if you keep the same filename, we use the SHA1 of the file to identify them and altering the image will cause problem at some point…

Also, have you changed the max_image_width and max_image_height settings? Seems like some images aren’t properly thumbnailed.

Ah well. In that case I hope at some future date there is built-in support for server-side image compression and resizing. I expect it will be a problem for any picture-heavy forum running on a virtual host, they don’t give you a whole lot of disk.

People on the site like to see detailed pictures so I did alter the image size. It doesn’t fit with the design well unfortunately, but it does put a large image up right away for them.

Scott

What you are asking for already exists, it is just that 10mb images are, well, 10mb images. Get a lot of those every day and you’ll need a lot of space. Or are you proposing that the server only store a 1000x1000 version of the 5000x5000 original image that was uploaded?

I would prefer to resize to something like 2000x2000, and reduce the quality if it was high. At some point images become so many pixels that a large pixel size has almost as much downside as upside for the average viewer: if you hit the zoom you only see a small portion of it. Converting 4000x4000 high quality to 2000x2000 medium quality would reduce the space by 5-6x and could solve my long-term hosting problem.

Scott

1 Like

Sure @zogstrip maybe you can add to your long term todo list, to set an absolute maximum dimension width x height of images that we will store on disk, anything larger than that gets auto resized to the max width x height and saved to disk.

So that way if they upload a 10mb 5000 x 5000 image only a 2mb 1000 x 1000 image will be saved to disk and shown to users. (This should not affect thumbnails)

Longer term we need multiple thumbnail sizes anyway to fix mobile bouncing issues.

Great, I’m sleeping better already :smile:

More like 400kb - 1/25th the pixels.

This was completed a while ago.

1 Like