source ################################################ # shiegege resize and save v.1 # shiegege@yahoo.com ################################################ # ONLINE SAMPLE PREVIEW : # http://kentung.f2o.org/scripts/thumbnail/resize.php ################################################ # readme: # + Need GD_Library on your server # + If your GD not support 'ImageCreateTrueColor' function, # change one line from 'ImageCreateTrueColor' to 'ImageCreate' # + Jpeg file format Only # Other file format, just modify the scripts # ex: # to create PNG file format: # change this lines: # - imagejpeg =WITH=> imagepng # - Header("Content-Type: image/jpeg") =WITH=> # Header("Content-Type: image/png") # - ImageCreateFromjpeg =WITH=> ImageCreateFrompng ################################################ # Please Edit ################################################ ## CONFIG ## $picture_location="./foto.jpg"; // picture locarion $picture_save="./foto_thumb.jpg"; // picture save location $size=100; // thumbnail size (pixels) ## /CONFIG ## $img_des=resize_img($picture_location,$size); # to display thumbnail, type this : # imagejpeg($img_des); # OR # use this to save picture : # imagejpeg($img_des,$picture_save); # OR # U can show thumbnail and # save thumbnail to a file together : # imagejpeg($img_des); # imagejpeg($img_des,$picture_save); imagejpeg($img_des); // only thumbnail picture ########################################## ##### Stop Edit ########################## ########################################## function resize_img($imgname,$size) { Header("Content-Type: image/jpeg"); $img_src = ImageCreateFromjpeg ($imgname); $true_width = imagesx($img_src); $true_height = imagesy($img_src); if ($true_width>=$true_height) { $width=$size; $height = ($width/$true_width)*$true_height; } else { $height=$size; $width = ($height/$true_height)*$true_width; } $img_des = ImageCreateTrueColor($width,$height); imagecopyresized ($img_des, $img_src, 0, 0, 0, 0, $width, $height, $true_width, $true_height); return $img_des; } ?>