See the http://php.com.ua/ru/articles/bicycles/thumbs.htm
<?
function thumb($path,$x,$y=0)
{
if (is_file($path)) {
$t=getimagesize ($path) or die('Unknown type of image');
$with=$t[0];
$height=$t[1];
switch ($t[2])
{
case 1:
$type='GIF';
$img=imagecreatefromgif($path);
break;
case 2:
$type='JPEG';
$img=imagecreatefromjpeg($path);
break;
case 3:
$type='PNG';
$img=imagecreatefrompng($path);
break;
}
if($y==0)
{$y=$x*($height/$with);}
header("Content-type: image/".$type);
$thumb=ImageCreateTrueColor($x,$y); // Do not use imagecreate !!!!!!
imagecopyresized($thumb,$img,0,0,0,0,$x,$y,$with,$height);
$thumb=imagejpeg($thumb);
return $thumb;
}
}
if($id)
{
echo thumb($id,100);
}
// for example: <img src="thumb.php?id=some_pict.jpg">
?>