PHP getimagesize is freaking slow !

Status
Not open for further replies.

Porsche_maniak

Active Member
283
2009
0
40
Hi there !
I've realized that the getimagesize function adds min 10 sec to the loading of my site !
So it would be really cool if it is possible to replace it with much faster function (i've heard that the dimensions of the image are in the first bytes).
Or atleast is there way to load firstly the entire page and then getting image size and loading img...
 
8 comments
10 seconds :/ that's ridiculous, try update the library, and create a seperate script away from your application to test it.

Your site should never take more then .500ms to compile, anything else is your GUI data such as images,css,html and other factors.
 
The images are not hosted on the local mashine.
That's why getimagesize is so slow.

There's the GD lib info :
Code:
array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(false) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(true) }

Using PHP 5.3.1
 
Code:
 $img_size = @getimagesize( $str_url );
          if ( $img_size !== false ) {
            $width = $img_size[0];
            $height = $img_size[1];

where $str_url is the image url..
And thats in the beggining of the page.
And i don't think that i can move it at the bottom so it will load last ?
 
i agree with magca. cache it somehow... so that when people visits your site the php script only reads from the database...

it should do all this stuff only when you insert it.
 
Hmm or maybe to store thumbnails from the remote images and if there is thumbnail show it first, on dblclick use getimagesize and expand the real image to its dimensions.
But it will be hell long coding.
 
Status
Not open for further replies.
Back
Top