I have a number of images who's information is stored in a MySQL database. The images themselves are stored in a folder, but the database contains their URL as well as other pertinent data.
I came across the PHP getimagesize
which I was thinking of using to populate the width=
and height=
properties of the img
tags of each image. However, I have been told that the overhead for this (as there are hundreds of images) will slow down the page load substantially.
I'm curious if there is a way to use getimagesize
to search out all the images from their information in the database, calculate their width
and height
, and then insert the data into their respective width
and height
fields in the database, Thus allowing a simple sql query to do the work?
Here is my database structure:
CREATE TABLE `secondary_images` (
`imgId` int(10) unsigned NOT NULL AUTO_INCREMENT,
`primaryId` int(10) unsigned DEFAULT NULL,
`imgURL` varchar(255) DEFAULT NULL,
`width` varchar(255) DEFAULT NULL,
`height` varchar(255) DEFAULT NULL,
PRIMARY KEY (`imgId`),
KEY `primaryId` (`primaryId`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;