php制作缩略图图片
<?php if (! 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"] ); } } ?>Insert title here