PHP image processing using the imagecopyresampled function clipping picture example,
Picture clipping refers to a large background image to cut out a specified area of the picture, the common application is when the user set up a profile picture, you can from the uploaded images, cut out a suitable area for their own profile picture. Image cropping is similar to image scaling, so it is also possible to use the imagecopyresampled () function to implement this function. Also in the JPEG image format as an example, declare an image clipping function cut (), the code is as follows:
Copy the Code code as follows:
<?php
Crop a picture of a specified area in a large background image, for example in JPEG image format
function Cut ($filename, $x, $y, $width, $height) {
$back = Imagecreatetruecolor ($width, $height);
Create a resource that can save the cropped picture
$cutimg = Imagecreatetruecolor ($width, $height);
Crop a picture using the imagecopyresampled () function
Imagecopyresampled ($cutimg, $back, 0,0, $x, $y, $width, $height, $width, $height);
Save the cropped picture and prefix the cropped picture if you don't want to overwrite the picture
Imagejpeg ($cutimg, $filename);
Imagedestroy ($CUTIMG);
Imagedestroy ($back);
}
Cut ("Brophp.jpg", 50, 50, 200, 200);
?>
http://www.bkjia.com/PHPjc/914053.html www.bkjia.com true http://www.bkjia.com/PHPjc/914053.html techarticle PHP image processing using the imagecopyresampled function clipping picture example, picture clipping refers to a large background image to cut out a specified area of the picture, the common application is in the user ...