php制作缩略图图片
<?phpif (! isset ( $_POST ["submit"] )) { echo "<?xml version=\"1.0\" encoding=\"UTF-8\"";} else { if (isset ( $_FILES ["file"] ) || $_POST ["file"] != "") { function resizeimage($file, $rate = .5) { $size = getimagesize ( $file ); switch ($size [2]) { case 1 : $img = imagecreatefromgif ( $file ); break; case 2 : $img = imagecreatefromjpeg ( $file ); break; case 3 : $img = imagecreatefrompng ( $file ); break; } $srcw = imagesx ( $img ); $srch = imagesy ( $img ); $detw = floor ( $srcw * $rate ); $deth = floor ( $srch * $rate ); $im = imagecreatetruecolor ( $detw, $deth ); $black = imagecolorallocate ( $im, 255, 255, 255 ); imagefilledrectangle ( $im, 0, 0, $detw, $deth, $black ); imagecopyresized ( $im, $img, 0, 0, 0, 0, $detw, $deth, $srcw, $srch ); header ( 'Content-type:image/png' ); imagepng ( $im ); imagedestroy ( $im ); imagedestroy ( $img ); } resizeimage ( $_FILES ["file"] ["tmp_name"] ); }}?><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><style type="text/css">td { margin: 0;}</style><script type="text/javascript">function submit(){ obj=document.form1.submit(); return obj;}</script>