Image resize,crop with gd afresh every time or caching?
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 (some开发者_开发知识库thing with ImageMagicks' convert won't work).
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.
精彩评论