PHP drawing the method of loading external images, _php tutorial

Source: Internet
Author: User
Tags image identifier

PHP drawings to load external images of the method,


This article describes the method of loading external images in PHP drawings. Share to everyone for your reference. The implementation method is as follows:

In the actual application, is the common watermark function.
Copy the Code code as follows: <?php
1. Create a canvas
$im = Imagecreatetruecolor (300,200);//Create a new true color image, the default background is black, return the image identifier. There is also a function imagecreate has not been recommended for use.
2. Loading external images
$im _new = imagecreatefromjpeg ("baidu.jpg");//return image identifier
$im _new_info = getimagesize ("baidu.jpg");//Gets the image size and returns an array. The function does not need to use the GD library.
/*----
3. Copy the loaded picture to the canvas
Parameter description:
$im: Needless to say, it means the canvas;
$im _new: Source images, which are images loaded from the outside
(30,30): Place the loaded image in the canvas, in the upper-left corner
(0,0): Represents the loaded picture, starting from where. (0,0) Indicates the beginning of the upper-left corner, or only a portion of the image can be loaded.
(*,*): in *, can be the original picture width and height, can also be less than the width of the high, only part of the interception, with the above coordinates, to indicate the part of the interception
******/
Imagecopy ($im, $im _new,30,30,0,0, $im _new_info[0], $im _new_info[1]);//Returns a Boolean value
3. Output image
Header ("Content-type:image/png");
Imagepng ($im);//output to page. If there is a second argument [, $filename], the image is saved
4. Destroy the image and release the memory
Imagedestroy ($im);
?>

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/947209.html www.bkjia.com true http://www.bkjia.com/PHPjc/947209.html techarticle PHP Drawing of the method of loading external images, this article describes the PHP drawing of the method of loading external images. Share to everyone for your reference. The concrete implementation method is as follows: In the practical application ...

  • 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.