Вот функция из моего движка, бери изучай! Все что ты запрашивал делает. PHP: function resize_image($fileS,$fileD,$size_x=0,$size_y=0,$quality=65) { $uploadedfile = $fileS; ini_set("memory_limit", "64M"); //Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image list($width,$height)=getimagesize($uploadedfile); if (($size_x>0) && ($size_y==0)) { $newwidth=$size_x; $newheight= $height*($size_x/$width); } if (($size_x==0) && ($size_y>0)) { $newheight= $size_y; $newwidth= $width*($size_y/$height); } if (($size_x>0) && ($size_y>0)) { $newwidth=$size_x; $newheight= $height*($size_x/$width); if ($newheight>$size_y) { $newheight= $size_y; $newwidth= $width*($size_y/$height); } } if (($size_x==0) && ($size_y==0)) { $newheight= 120; $newwidth= $width*(120/$height); } $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = $fileD; imagejpeg($tmp,$filename,$quality); imagedestroy($src); imagedestroy($tmp); }