Forum Moderators: coopster
The original image sizes are 400x400 and are only displayed one at a time that way. The thumbnails are generated from the exact same script but are resized to 150x150 and then displayed up to 9 on a page. I've been noticing that the display of these thumbnails can be slow at times and I'm beginning to think I'd be better off actually storing each thumbnail as an actual image file and serving it that way, rather than depending on GD to do all the grunt work every time someone requests a page with 9 thumbnails.
Hopefully you can see what I mean.
I'm looking for thoughs, experiences with GD, and recommendations on this. I don't want to overtax the server displaying images, but I would also rather avoid storing tens of thousands of thumbnails if I can avoid it too.
Just how much power does GD take to create an image. How about 9 at the same time? How about if I've got 5 users at once requesting a total of 45 images being generated at the same time? The more I scale it up the more I start to think I'm better off sacrificing the storage.
Thanks!
It's just too slow to gen images on the fly, I always store them, you can have it be automated, made when you upload the photo or have a script you can run that will gen them for you.
size isn't much of an issue, they're thumbnails, they're supposed to be tiny.
Anything that slows things down for the user is an issue
<?php
$image_name = 'some-test-image.png';
$cache_file_name = $_SERVER['DOCUMENT_ROOT'].'/cache/'.$image_name;
$cache_age = ( 60 * 60 * 2 ); // two hours
if(
(file_exists($cache_file_name)) &&
(filemtime($cache_file_name) > ( time() - $cache_age ))
){
// then use the cached version
} else {
// rebuild the cached version and export it to the cache path
// your image/thumbnail generation code here, then export to the right place image*
// imagepng( $im, $cache_file_name );
}
echo '<img src="/cache/'.$image_name.'" />';
?>