Php+jquery online cut chart code [imitation dedecms]_php tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.