One way to improve page loading is to specify image dimesions (hieght width). In PHP this can be done with getimagesize(), however I can imagine this would be quite slow to execute if you have alot of images.
What is the best way to dynamically get image dimensions of many images with minimal effect on page loading. We are talking about 50+ images.
I’ve just tested with 55 pcs of 5+ MB images:
Imagemagick’s getImageGeometry took
5.3 seconds(because after each file you have to recreate the imagick object), while getimagesize went thru the images in0.032 seconds. The latter is more than acceptable.If not, store the dimensions in the database.
EDIT: Also, if you get the files through TCPIP, that slows down the process considerably. So, if you call it this way:
getimagesize('http://www.blabla.com/pic.jpg');Instead of
getimagesize('localdir/hereiam/pic.jpg');you get some network overhead.
Plus, if those pictures consistently have EXIF data (made with a digital camera), then you can use the PHP exif_ functions, like: exif_read_data.
Question: which PHP version you are using? Older 4.x versions had smaller problems regarding getimagesize on certain filesystems.