Phpgd library-based image creation method

Source: Internet
Author: User
Phpgd library-based image creation method

  1. $ Im = imagecreate (200,150 );
  2. Echo $ im;
  3. ?>
  4. // Output
  5. Resource id #1

2. magecreatetruecolor-create a true-color canvas 1 in the format of imagecreatetruecolor (int x_size, int y_size) 2. resolution: create a blank canvas like imagecreate, the difference is that the canvas created by this function supports more colors, so the effect is better. the input canvas width and height pixel values return the ID number allocated to the canvas by the system. for example:

  1. $ Im = imagecreatetruecolor (200,150 );
  2. Echo $ im;
  3. ?>
  4. // Output
  5. Resource id #2

3. imagecreatefromgif-create a canvas and read an image in gif format to this canvas 1. Format: imagecreatefromgif (string filename) 2. resolution: the input parameter is the file name (path added) of a GIF image. If the image is in another format, an error is reported. The system returns the ID number assigned to the canvas for calling other drawing functions, for example:

  1. $ Im = imagecreatefromgif ('gd _ image/gif.gif ');
  2. Echo $ im;
  3. ?>
  4. // Output
  5. Resource id #3

IV. imagecreatefromjpeg-create a canvas and read a jpg image to this canvas 1. Format: imagecreatefromjpeg (string filename) 2. resolution: the input parameter is the name of a jpg image (with a path). If an image of another format is used, an error is reported. The system returns the ID number assigned to the canvas for calling other drawing functions, for example:

  1. $ Im = imagecreatefromjpeg ('gd _ image/gif.jpg ');
  2. Echo $ im;
  3. ?>
  4. // Output
  5. Resource id #4

5. imagecreatefrompng-create a canvas and read a png image to this canvas 1. Format: imagecreatefrompng (string filename) 2. resolution: the input parameter is the file name (path added) of a png image. If the image is in another format, an error is reported. The system returns the ID number assigned to the canvas, used to call other drawing functions, for example:

  1. $ Im = imagecreatefromgif ('gd _ image/gif.gif ');
  2. Echo $ im;
  3. ?>
  4. // Output
  5. Resource id #4

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.