最近由于抓了网站的图片做demo,都太大了。 <style type="text/css"> *{font:12px verdana;} </style> <pre> <?php require_once("../include/echo.php"); foreach ($_POST as $k=>$v) { $$k = $v; } if ($checked==1) { $info = getimagesize ( $srcPicPath); //pr($info); $actualWidth = $info[0]; $height = $info[1]-$y; $imgsrc = ImageCreateFromPng($srcPicPath); $imgdest = imagecreatetruecolor($width, $height); imagecopy ( $imgdest, $imgsrc, 0, 0, $x, $y, $width, $height); imagepng($imgdest,$destPicPath); } //resize_jpg("picture.jpg",200,200); ?> <form name="adminForm" action="?" method="post" onsubmit="return checkForm();"> x : <input type="text" name="x" value="133" size="40" /> y : <input type="text" name="y" value="113" size="40" /> width : <input type="text" name="width" value="748" size="40" /> height : <input type="text" name="height" value="0" size="40" /> srcPicPath : <input type="text" name="srcPicPath" value="D:\docs\mypictures\p.cnnavi.com\Snap3.png" size="80" /> destPicPath : <input type="text" name="destPicPath" value="D:\docs\mypictures\p.cnnavi.com\out.png" size="80" /> <input type="hidden" name="checked" value="1" /> <input type="submit" value="submit" /> </form> <script language="javascript" type="text/javascript"> <!-- function checkForm(){ var form = document.adminForm; if(form.x.value ==""){ alert("x is empty"); form.x.focus(); return false; } else if(form.y.value ==""){ alert("y is empty"); form.y.focus(); return false; } else if(form.width.value ==""){ alert("width is empty"); form.width.focus(); return false; } else if(form.height.value ==""){ alert("height is empty"); form.height.focus(); return false; } else if(form.srcPicPath.value ==""){ alert("srcPicPath is empty"); form.srcPicPath.focus(); return false; } else if(form.destPicPath.value ==""){ alert("destPicPath is empty"); form.destPicPath.focus(); return false; } }// /func //--> </script>