Draw a picture onto the canvas: Imagecopy ()

Source: Internet
Author: User
Tags imagecopy

<?PHP//1. Drawing an image resource (creating a canvas)$image= Imagecreatetruecolor (500, 300);//2. First assign a green$green= Imagecolorallocate ($image, 22, 153, 0);//3. Fill the canvas with greenImagefill ($image, 0, 0,$green);//4. Drawing images in the canvas$bai= Imagecolorallocate ($image, 255, 255, 255);//parameter 1: $DST _img destination, Target image resource//Parameter 2: $SRC _img original source, created by imagecreatefromjpeg PNG//Parameter 3, 4: Target image resource X, y coordinate//parameter 5, 6: The beginning of the original collection x, y coordinates//Parameters 7, 8: The original width, height$src _img= Imagecreatefrompng (' bs.png ');//Get the height of the image resource by using PHP's function imagesx () to obtain the width of the image resource, Imagesy ()$src _w= Imagesx ($src _img);$src _h= Imagesy ($src _img); Imagecopy ($image,$src _img, 0, 0, 0, 0,$src _w,$src _h);//5. Output image resources directly in the browserHeader("Content-type:image/jpeg"); Imagejpeg ($image);//6. Destroying image ResourcesImagedestroy ($image);

Draw a picture onto the canvas: Imagecopy ()

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.