I’m building a image sharing site and would like to know the pros and cons of resizing images on the fly with PHP and having the resized images stored.
Which is faster?
Which is more reliable?
How big is the gap between the two methods in speed and performance?
Please note that either way the images go through a PHP script for statistics like views or if hotlinking is allow etc… so is not like it will be a direct link for images if I opt to store the resize images.
I’ll appreciated your comments or any helpful links on the subject.
This sounds like premature optimisation. Do you know how many users your site will have/ how much computational grunt your server(s) will have? Go with the simplest (maintenance-wise) option, i.e. resize on the fly, until performance becomes an issue, then figure out from there what to do.
It might be an idea to implement some sort of server side caching of your rescaled images, if they’re likely to be repeatedly hit, but I don’t think this need extend as far as explicit pre-rendering.