File size: 1.04Kb
<?
function rsh($fname)
{
$pos = StrPos('@'.$fname,'.');
if($pos)
{
$ps = Strrpos($fname,'.');
$rsh_name = substr($fname,$ps+1);
}
else
{ $rsh_name = ''; }
return $rsh_name;
}
if(IsSet($pic))
{
$rsh = rsh($pic);
if($rsh!='jpg' && $rsh!='png' && $rsh!='gif') exit;
if($rsh=='jpg') $img = imageCreateFromjpeg('./'.$pic);
if($rsh=='png') $img = imageCreateFrompng('./'.$pic);
if($rsh=='gif') $img = imageCreateFromgif('./'.$pic);
if(!IsSet($h)) $h = ImageSY($img);
if(!IsSet($w)) $w = ImageSX($img);
if($h<1) $h = ImageSY($img);
if($w<1) $w = ImageSX($img);
$img2 = ImageCreate($w,$h);
imageCopyResized($img2, $img, 1, 1, 1, 1, $w,$h, imageSX($img), imageSY($img));
if($rsh=='jpg') header("Content-type: image/jpeg");
if($rsh=='png') header("Content-type: image/png");
if($rsh=='gif') header("Content-type: image/gif");
if($rsh=='jpg') imagejpeg($img2);
if($rsh=='png') imagepng($img2);
if($rsh=='gif') imagegif($img2);
imageDestroy($img);
imageDestroy($img2);
}
?>