'Best method to server-side img compress from full src img [closed]

I want to display a simple image gallery on a PHP webpage where the images are compressed; however, it allows for full res jpegs to be downloaded. And I'm just curious what method you would recommend for a project like this?

I'm thinking I store the full-res jpeg on my server and use server-side PHP imagecreatefromjpeg() and imagejpeg() to create a lower-res thumbnail of the image with an option to download? Or I suppose I could store lower res and high res jpegs both on the server and just echo them out but I would rather not store the lower res if possible.

Are there any other options for a project like this? And if imagejepg() is a good option, would someone direct me in how to use it?

php


Solution 1:[1]

Lower-rez images typically take much less disk space, much less, than hi-rez images. Disk space is extremely unlikely to be a limiting factor when you pre-create the smaller images.

And, resizing and decompressing on the fly in response to user requests eats server power. Store the low-rez images: think green.

For what it's worth, WordPress (40% of web servers on the net) resizes on upload and stores resized images, so that approach is proven effective.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 O. Jones