<?php
error_reporting(0);
$sc=$_SERVER['SCRIPT_NAME'];
$sc=str_replace("img.php","",$sc);
$tou="image/tx";
$name=$_GET['t'];
$path=$_SERVER['DOCUMENT_ROOT']."{$sc}{$tou}/{$name}";
if(!file_exists($path)){

$path=$_SERVER['DOCUMENT_ROOT']."{$sc}{$tou}/tx.jpg";
}
$infor=getimagesize($path);
list($width,$height)=$infor;//获取源图尺寸
$mime=$infor[mime];
$nw=50;
$nh=50;
$dst=imagecreatetruecolor($nw,$nh); //创建一幅真彩画板
 if(stristr($mime,"jpeg")){
$src=imagecreatefromjpeg($path);//获取源图
imagecopyresized($dst,$src,0,0,0,0,$nw,$nh,$width,$height);

imagejpeg($dst);//输出图片

}elseif(stristr($mime,"gif")){
$src=imagecreatefromgif($path);
imagecopyresized($dst,$src,0,0,0,0,$nw,$nh,$width,$height);

imagegif($dst);
}elseif(stristr($mime,"png")){
$src=imagecreatefrompng($path);
imagecopyresized($dst,$src,0,0,0,0,$nw,$nh,$width,$height);
imagepng($dst);
}
imagedestroy($dst);
?>