The simplest way for PHP to cut images from the middle

Source: Internet
Author: User
PHP crop an image, which is generally the imagecopyresampled () function. By default, the image is cut from the upper left corner. After reading the code of cutting the image from the middle corner on the Internet, it is very complicated. In fact, you don't have to worry about this, just define the two horizontal and vertical coordinate strings in imagecopyresampled. The code in this article is as follows: crop from 1/3 width, Set width to 200, and height.

PHP crop an image, which is generally the imagecopyresampled () function. By default, the image is cut from the upper left corner. After reading the code of cutting the image from the middle corner on the Internet, it is very complicated. In fact, you don't have to worry about this, just define the two horizontal and vertical coordinate strings in imagecopyresampled. The code in this article is as follows: crop from 1/3 width, Set width to 200, and height.

PHP crop an image, which is generallyimagecopyresampled()Function, which is switched from the upper left corner by default. After reading the code for cutting graphs from the middle corner on the Internet, it is very complicated. In fact, this is not necessary, just define the two horizontal and vertical coordinate strings in imagecopyresampled.
Code effect of this article: crop from 1/3 width, Set width to 200, and the height remains unchanged. (If you want to cut from a certain proportion of the height and width, refer to this method)

 

Cut_img_from_center is coded by xiaohudie. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl

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.