Dysan
12-07-2007, 06:18 PM
Whats the quickest way of creating thumbnails from an image, then when the user clicks the thumbnail, the full size version of the image is displayed?
|
Click to See Complete Forum and Search --> : Quick Thumbnails! Dysan 12-07-2007, 06:18 PM Whats the quickest way of creating thumbnails from an image, then when the user clicks the thumbnail, the full size version of the image is displayed? holiday 12-07-2007, 06:33 PM here's a php function that that I made, it will except PNG, GIF and JPEG/JPG file formats and will export to a JPEG/JPG. <?php //Creat Function: resize photo and save function resize_photo_save($sourcefile, $destfile, $max_width = '', $max_height = '', $quality = '90') { //get image size $size = getimagesize($sourcefile); $width = $size[0]; $height = $size[1]; //set new size vars $new_width = $width; $new_height = $height; //check width size if($max_width) { if($new_width>$max_width) { $percent = $max_width / $new_width; $new_height = $new_height * $percent; $new_width = $max_width; } } //check height size if($max_height) { if($new_height>$max_height) { $percent = $max_height / $new_height; $new_height = $max_height; $new_width = $new_width * $percent; } } //round width and height to nerest whole number $new_width = round($new_width); $new_height = round($new_height); //determin image type $image_type = exif_imagetype($sourcefile); if($image_type=='1') { $img_src = imagecreatefromgif( $sourcefile ); } if($image_type=='2') { $img_src = imagecreatefromjpeg( $sourcefile ); } if($image_type=='3') { $img_src = imagecreatefrompng( $sourcefile ); } //check for valid image type if(!$img_src) { return '0'; } else { //create new image, resample old image, save new image and destroy all temp files $img_dst = imagecreatetruecolor( $new_width, $new_height); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $width, $height); if(!imagejpeg($img_dst, $destfile, $quality)) { return '0'; } else { return '1'; } imagedestroy($img_src); imagedestroy($img_dst); } } ?> Dysan 12-07-2007, 07:39 PM How do I do this through just html? Creating the thumbnails manually, then display the full size image on a different page when the thumbnail is clicked? holiday 12-07-2007, 08:34 PM <a href="big_image.jpg" target="_blank"><img src="small_image.jpg" /></a> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |