Php+jquery online cut chart code [anti-DEDECMS]
<title>Cropper</title>
AJAX Image cropper-yui-based
HTML Blog
The above is the index.php file
Use PHP to re-plot according to X, y
Get variables
$imgfile = $_get[' image '];
$cropStartX = $_get[' Cropstartx ');
$cropStartY = $_get[' Cropstarty ');
$cropW = $_get[' cropwidth ');
$cropH = $_get[' cropheight ');
Create a images
$origimg = Imagecreatefromjpeg ($imgfile);
$cropimg = Imagecreatetruecolor ($cropW, $cropH);
Get the original size
List ($width, $height) = getimagesize ($imgfile);
Crop
Imagecopyresized ($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width, $height);
Force download NES image
Header ("Content-type:image/jpeg");
Header (' content-disposition:attachment; Filename= '. $imgfile. ');
Imagejpeg ($CROPIMG);
Destroy the images
Imagedestroy ($CROPIMG);
Imagedestroy ($ORIGIMG);
?>
Here's the picture,
if (!empty ($_files["Uploadimage")) {
Get file name
$filename = basename ($_files[' uploadimage ' [' name ']);
Get extension
$ext = substr ($filename, Strrpos ($filename, '. ') + 1);
Check for JPG only
if ($ext = = "jpg") {
Generate Unique file name
$newName = ' images/'. Time (). '. '. $ext;
Upload files
if ((Move_uploaded_file ($_files[' uploadimage ' [' tmp_name '], $newName))) {
Get height and width for image uploaded
List ($width, $height) = getimagesize ($newName);
Return JSON data
Echo ' {"image": "'. $newName. '", "height": "'. $height. '", "width": "'. $width. '} ';
}
else {
Echo ' {"error": "An error occurred while moving the files"} ";
}
}
else {
Echo ' {' Error ': ' Invalid image format '} ';
}
}
?>
http://www.bkjia.com/PHPjc/632002.html www.bkjia.com true http://www.bkjia.com/PHPjc/632002.html techarticle php+jquery Online cut chart code [anti-DEDECMS]! DOCTYPE HTML Public-//w3c//dtd XHTML 1.0 transitional//en HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD HTML XMLNS=HTTP://WWW.W ...