hi. I'm setting up a sort of photo gallery, and what I want is for the script to pull the images from a folder, make thumbnails from them, and automatically generate links so when i click the thumbnails, they'll appear larger in a box above the thumbs. Preferably they'd be loading off of the server as they were requested. Is this even possible? If it is, I'd love to be directed to some helpful resources because I'm new to this and right now I'm just working off of assumptions. Tutorials would be amazingly helpful.
// Add GIF support if GD was compiled with it
if (function_exists('ImageCreateFromGif')) { $functions['image/gif'] = 'ImageCreateFromGif'; }
$size = getimagesize($infile);
// Check if mime type is listed above
if (!$function = $functions[$size['mime']]) {
trigger_error("MIME Type unsupported: {$size['mime']}",E_USER_WARNING);
return FALSE;
}
// Open source image
if (!$source_img = $function($infile)) {
trigger_error("Unable to open source file: $infile",E_USER_WARNING);
return FALSE;
}
// Create new image
$new_img = imagecreatetruecolor($neww,$newh);
// Copy and resize image
imagecopyresized($new_img,$source_img,0,0,0,0,$neww,$newh,$size[0],$size[1]);
// Save output file
if ($save_function == 'imagejpeg') {
// Change the JPEG quality here
if (!$save_function($new_img,$outfile,75)) {
trigger_error("Unable to save output image",E_USER_WARNING);
return FALSE;
}
} else {
if (!$save_function($new_img,$outfile)) {
trigger_error("Unable to save output image",E_USER_WARNING);
return FALSE;
}
}
Bookmarks