$thumb_width || $orig_h > $thumb_height) { if($orig_w >= $orig_h) { $new_w = $thumb_width; $diff = $new_w / $orig_w; $new_h = $orig_h * $diff; } if($orig_h > $orig_w) { $new_h = $thumb_height; $diff = $new_h / $orig_h; $new_w = $orig_w * $diff; } } else { $new_h = $orig_h; $new_w = $orig_w; } // Generate image object $dst_img = imagecreatetruecolor($new_w, $new_h); // Copy image and resize imagecopyresized($dst_img, $true_img, 0, 0, 0, 0, $new_w, $new_h, $orig_w, $orig_h); // Copy thumbnail to location based on extension $thumb_path = $dir."thumbnails/".$uniq; switch($ext) { case "gif": imagegif($dst_img, $thumb_path); break; case "jpg": imagejpeg($dst_img, $thumb_path); break; case "jpeg"; imagejpeg($dst_img, $thumb_path); break; case "png"; imagepng($dst_img, $thumb_path); break; } $r = @move_uploaded_file($src, $thumb_path); echo $r; $thumb = $thumb_path; $image = $src_img; } else { $error = true; echo "The image could not be copied"; if($reason == "incorrect") { echo ", because the image's filetype is not supported"; } } ?>