<?
function OutThumb($src, $w, $h){
$size = getimagesize($src);
if( $size[2] == 2 ){$im = @imagecreatefromjpeg($src);}
elseif( $size[2] == 1 ){$im = @imagecreatefromgif($src);}
elseif( $size[2] == 3 ){$im = @imagecreatefrompng($src);}
$oldwidth = $size[0];
$oldheight = $size[1];
if($w == ''){
$newwidth = ($h / $oldheight) * $oldwidth;
}else{
$newwidth = $w;
}
if($h == ''){
$newheight = ($w / $oldwidth) * $oldheight;
}else{
$newheight = $h;
}
if($size[2] != 1){
$new = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($new, $im, 0, 0, 0, 0, $newwidth, $newheight, $size[0], $size[1]);
}
else{
$new = imagecreate($newwidth, $newheight);
imagecopyresized($new, $im, 0, 0, 0, 0, $newwidth, $newheight, $size[0], $size[1]);
}
header('Content-Type: ' . $size['mime']);
if( $size[2] == 2 ){@imagejpeg($new, '', 100);}
elseif( $size[2] == 1 ){@imagegif($new);}
elseif( $size[2] == 3 ){@imagepng($new);}
@imagedestroy($im);
@imagedestroy($new);
}
$path = $_GET['image'];
$w = $_GET['w'];
$h = $_GET['h'];
OutThumb($path, $w, $h);
?>