Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store multiple sizes of an image or just store the main and resize?

I'm working on a CMS and I'm trying to figure out the common practice for doing a REST style image request. I have three sizes, small, medium, and full. My thought is to store only the full and write a function that will resize on each page request. This has obvious cpu costs. The other end is that I could store all three sizes and only calculate on upload, this seems to waste space.

My environment is an intranet, so relatively low requests and a high number of images stored. Thoughts?

Note: I realize I don't have to really worry too much since it's intranet and either solution will work, just wondering which would be preferred for knowledge sake.

like image 480
brandon Avatar asked Dec 10 '25 20:12

brandon


1 Answers

Another option is to maintain a cache of resized images. Serve up the ones that are available. Create new ones if they are not available. Delete images that have not been requested for a while.

This will be a compromise between the CPU and storage issues.

like image 129
Jeffrey L Whitledge Avatar answered Dec 12 '25 08:12

Jeffrey L Whitledge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!