اتمنى هذه الداله تفيدك // 
	كود PHP:
	
function createthumb($name, $ext, $filename, $new_w, $new_h)
{
    if (preg_match("/jpg|jpeg/", $ext)) {
        $src_img = imagecreatefromjpeg($name);
    } elseif (preg_match("/png/", $ext)) {
        $src_img = imagecreatefrompng($name);
    } elseif (preg_match("/gif/", $ext)) {
        $src_img = imagecreatefromgif($name);
    }
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    if ($old_x > $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $old_y * ($new_h / $old_x);
    } elseif ($old_x < $old_y) {
        $thumb_w = $old_x * ($new_w / $old_y);
        $thumb_h = $new_h;
    } elseif ($old_x == $old_y) {
        $thumb_w = $new_w;
        $thumb_h = $new_h;
    }
    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    if (preg_match("/jpg|jpeg/", $ext)) {
        imagejpeg($dst_img, $filename);
    } elseif (preg_match("/png/", $ext)) {
        imagepng($dst_img, $filename);
    } elseif (preg_match("/gif/", $ext)) {
        imagegif($dst_img, $filename);
    }
    imagedestroy($dst_img);
    imagedestroy($src_img);
} 
 مع التعديل لما يناسب