tags:

views:

90

answers:

1

I found this really nice function that receives your desired proportions and resizes/crops the image for you. The function requires ImageMagick to work.

Will it be better to cache the image or resize it every time? I'm pretty sure using gd will be slower than caching, but it won't require me to use ImageMagick, and I still haven't successfully tweaked it (something with ImageMagicks' convert won't work).

+6  A: 

Image generation functions are very expensive. Caching will almost always be significantly faster, and isn't that hard to implement. Come up with a quick naming scheme that will take into account the size of the image ('userid-123-200x400.jpg') and uniquely identify it, and when time comes to serve it, just check if it's there and generate it and save it into a cache directory if necessary.

Disk space is cheaper than CPU and scales much better, and your page load times will thank you for it.

zombat
+2 ------------
Mark