This article mainly introduces the usage of the PHP image processing function imagecopyresampled, and analyzes the function, parameters, and usage of the imagecopyresampled function in detail with examples. Friends in need can refer to it
Grammar
Copy codeThe code is as follows:
bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
Parameters
dst_image | Target image connection resource. |
src_image | Source image connection resource. |
dst_x | Target X coordinate point. |
dst_y | Target Y coordinate point. |
src_x | The X coordinate point of the source. |
src_y | The Y coordinate point of the source. |
dst_w | Target width. |
dst_h | Target height. |
src_w | The width of the source image. |
src_h | The height of the source image. |
Returns TRUE on success, or FALSE on failure.
Case
Case (image cropping):
Case 2 (resampling) :
$ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // 重新取样 $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // 输出 imagejpeg($image_p, null, 100); ?>
Attached are three ideas for uploading pictures
1 .Select the picture, submit the form, the server handles the upload uniformly, save the path
2.Select the picture, upload, get the path, submit the form, save the path
3. Select the picture, upload it to the server, obtain the picture from the server through some means, and save it locally
The above is the entire content of this article, I hope it will be helpful to everyone learning helps.
Related recommendations:
Variable setting and destruction of php extension development
PHP asynchronous processing - uploading files
##php file search(file search)
The above is the detailed content of Usage of php image processing function imagecopyresampled. For more information, please follow other related articles on the PHP Chinese website!