<?php $img = ''; $thumbnail_width = 100; $thumbnail_height = 100; $img_arr = explode(".", $img); $arr_image_details = getimagesize($updir.$img); $original_width = $arr_image_details[0]; $original_height = $arr_image_details[1]; if ($original_width > $original_height) { $new_width = $thumbnail_width; $new_height = round($original_height / ($original_width / $thumbnail_width)); } else { $new_height = $thumbnail_height; $new_width = round($original_width / ($original_height / $thumbnail_height)); } if ($arr_image_details[2] == 1) { $imgt = "ImageJPEG"; $imgcreatefrom = "ImageCreateFromGIF"; } if ($arr_image_details[2] == 2) { $imgt = "ImageJPEG"; $imgcreatefrom = "ImageCreateFromJPEG"; } if ($arr_image_details[2] == 3) { $imgt = "ImageJPEG"; $imgcreatefrom = "ImageCreateFromPNG"; } if ($imgt) { $old_image = $imgcreatefrom("$updir"."$img"); $new_image = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $original_width, $original_height); $imgt($new_image, $updir.$img_arr[$key]."s.jpg"); } ?>