i have finished the four parts of your automatic image gallery tutorial. Almost everything works fine except that all the thumbnails are black. I'll thought that the problem might be in the imagecreatetruecolor or that the path to the thumbnails is wrong, but whatever i do, the thumbnails are staying black.
Hopefully someone can help me out.
<?php if (isset($_GET['img'])){ if (file_exists($_GET['img'])){ ignore_user_abort(true); set_time_limit(120); ini_set('memory_limit', '512M'); $src_size = getimagesize($_GET['img']); if ($src_size === false){ die('Dit is geen afbeelding.'); } $thumb_width = 250; $thumb_height = 200; if ($src_size['mime'] === 'image/jpeg'){ $src = imagecreatefromjpeg($_GET['img']); }else if ($src_size['mime'] === 'image/png'){ $src = imagecreatefrompng($_GET['img']); }else if ($src_size['mime'] === 'image/gif'){ $src = imagecreatefromgif($_GET['img']); } $thumb = imagecreatetruecolor($thumb_width, $thumb_height); if ($src_size['mime'] === 'image/jpeg'){ imagejpeg($thumb, "thumbs/{$_GET['img']}"); }else if ($src_size['mime'] === 'image/png'){ imagepng($thumb, "thumbs/{$_GET['img']}"); }else if ($src_size['mime'] === 'image/gif'){ imagegif($thumb, "thumbs/{$_GET['img']}"); } header("location: thumbs/{$_GET['img']}"); } die(); } if (is_dir('./thumbs') === false){ mkdir('./thumbs', 0744); } $images = glob('*.{jpg,jpeg,png,gif}', GLOB_BRACE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> a, img {float:left;} </style> <title>Untitled Document</title> </head> <body> <div> <?php foreach ($images as $image){ if (file_exists("./thumbs/{$image}")){ echo "<a href=\"{$image}\"><img src=\"thumbs/{$image}\" alt=\"{$image}\" /></a>"; }else{ echo "<a href=\"{$image}\"><img src=\"?img={$image}\" alt=\"{$image}\" /></a>"; } } ?> </div>