GENERATING THUMBNAIL IMAGES $result = ‘Problem copying original’; (Web page design)

GENERATING THUMBNAIL IMAGES $result = ‘Problem copying original’; } else { // calculate the dimensions of the thumbnail $thumb_width = round($width * $ratio); $thumb_height = round($height * $ratio); // create an image resource for the thumbnail $thumb = imagecreatetruecolor($thumb_width, $thumb_height); // create the resized copy imagecopyresampled($thumb, $source, 0, 0, 0, 0, $thumb_width, . $thumb_height, $width, $height); // save the resized copy switch($type) { case 1: if (function_exists(’imagegif’)) { $success = imagegif($thumb, THUMBS_DIR.$name.’_thb.gif’); $thumb_name = $name.’_thb.gif’; } else { $success = imagejpeg($thumb, THUMBS_DIR.$name.’_thb.jpg’,50); $thumb_name = $name.’_thb.jpg’; } break; case 2: $success = imagejpeg($thumb, THUMBS_DIR.$name.’_thb.jpg’, 100); $thumb_name = $name.’_thb.jpg’; break; case 3: $success = imagepng($thumb, THUMBS_DIR.$name.’_thb.png’); $thumb_name = $name.’_thb.png’; } if ($success) { $result = “$thumb_name created”; } else { $result = ‘Problem creating thumbnail’; } // remove the image resources from memory imagedestroy($source); imagedestroy($thumb); } } ?> As the script now stands, it looks for the name of an image submitted from a form as $_POST[’pix’], and located on the server in whatever you have defined as SOURCE_DIR. To create a thumbnail from an uploaded image, you need to adapt the script so that it processes the temporary upload file. 225
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Leave a Reply