what is happening when i upload a photo, my script creates a thumbnail at the size of 120x120. which is the perfect size.
only problem is that when it is a long photo or a wide photo it will just shrink the picture and make the thumbnail quite awful looking as the ratio is distorted.
is there a way to just get the center of a picture instead of using the whole photo to base the thumbnail creation upon.
here is the current code.
if($_POST['submit']) //If submit is hit
$dirpics = "memberspics";
$dirthumbs = "membersthumbs";
$destpic = $dirpics."/".$image_name;
$src_image = imagecreatefromjpeg($_FILES['image']['tmp_name']); //load the uploaded image into memory for manipulation
$src_width = imagesx($src_image); //original width
$src_height = imagesy($src_image); //original height
$src_ratio = $src_height / $src_width; //width and height ratio to preserve aspect ratio for thumbnail
$thumb_width = 120; //fixed the thumbnail width
$thumb_height = 120; //get thumbnail height according to thumbnail width * the ratio
$thumb_image = imagecreatetruecolor($thumb_width, $thumb_height); //create blank image for thumbnail
imagecopyresized($thumb_image, $src_image, 0,0,0,0, $thumb_width, $thumb_height, $src_width, $src_height); //create thumbnail from source image
imagejpeg($thumb_image, "membersthumbs/thumbnail.jpg"); //save thumbnail as