Kód:
function make_th($fname, $ext)
{
$fname2 = "../img/fotoz/".$fname;

if ($ext == "jpg")
	{
	$imgsrc = imagecreatefromjpeg($fname2);
	}
else if ($ext == "png")
	{
	$imgsrc = imagecreatefrompng($fname2);
	}
else if ($ext == "gif")
	{
	$imgsrc = imagecreatefromgif($fname2);
	}

$sx = imagesx($imgsrc);
$sy = imagesy($imgsrc);

$STD_X = 150;
$ratio = $STD_X/$sx;

$tx = $STD_X;
$ty = $sy * $ratio;

$imgdst = imagecreatetruecolor($tx, $ty);

imagecopyresized($imgdst, $imgsrc, 0,0,0,0,$tx,$ty,$sx,$sy);
//header ("content-type: image/png");
$x = imagepng($imgdst, "../img/fotoz/th_".$fname.".png");
return $x;
}
je to vytrzeny z kontextu, ale snad pochopis o co jde..