5 ms·
I'm curoius why everyone resizes images when they're uploaded. I think the better way is not in any way changing the uploaded file, instead resizing it when it
by ilyak 17y ago
I'm curoius why everyone resizes images when they're uploaded.
I think the better way is not in any way changing the uploaded file, instead resizing it when it's actually requested by a client.
This way, your pages can ask server for whatever actual size they need in the moment instead of setting image size once in stone.
Like, if you've uploaded kitty.jpg, you can then ask for kitty_120x50.jpg or kitty_300x.jpg or kitty_x200.jpg (with missing dimension being calculated to preserve ratio).
If course, resized files are stored along with the original to avoid costly resizing process each time. If there's already a copy with required sizes, it's served really, really fast.
- mikeryan 17y agoThis is one of those issues where I have an opinion but I honestly don't care that much either way. If the place I worked had one method in place I'd probably do that. The nice thing about doing it on upload is It allows you to offload the processing to a job queue so you don't take a huge performance hit. (This is what I've done in the past). If you're resizing to sizes not relative to the original it also gives you the ability to maybe do some editing/cropping to make sure the resized images still make sense. Digg has a tool like this for avatar images.
- fnid 17y agoThe upload process is already time consuming. Doesn't hurt it much to include the resize processing with the upload. People want the images to appear quickly every time. Disk space is cheap and you want requests to images to go to the regular file serving (.jpg or .html) rather than through dynamic serving (.php or .aspx) to reduce load on the server.
- nullstyle 17y agoIt's not about the time it takes to resize a new image, it's about the time it takes to change _all_ of your images when design changes happen. a preprocess-only system means that you need to have a migration system in place, and it means that your designers have just a little more overhead to make tweaks. It's manageable, but producing the images on demand makes for a more easily changed system with fewer moving parts.
- ericwaller 17y agoI think amazon.com does something like this. I read an article that dissected their product image urls to explain how their image service worked but I can't find it now. If I remember correctly the service could resize/rotate, add sale "stickers," and a bunch of other stuff. EDIT found the article: http://aaugh.com/imageabuse.html http://aaugh.com/imageabuse.html
- ilyak 17y agoYeah, adding stickers on the fly is also the way to go.