PHP GD Library related image generation and processing function summary _php skills

Source: Internet
Author: User

This paper summarizes the PHP GD library related image generation and processing functions. Share to everyone for your reference, specific as follows:

These days in the study of image verification code, reference to many examples, are using the GD library to generate and draw images, so the GD library is intended to encapsulate the class to use, and also learn and practice the PHP object-oriented section.

First analysis of the functions provided by the GD library, according to the function of the division: (This is a commonly used basic-level functions, more advanced functions to be studied later)

1. Create//Image generation

A. Drawing images

Imagecreate//color palette (256-color) (gif/*)
Imagecreatetruecolor//Based on True color images (cannot be used to generate GIF images)

B. Creating images from images

imagecreatefrom* (*=GD2/GD2PART/GD/GIF/JPEG/PNG/STRING/WBMP/XBM/XPM)//create image from image

C.copy

Imagecopy//Copy Local image
Imagecopymerge//Copy and merge local image
Imagecopymergegray//Copy and merge local image (grayscale)
imagecopyresampled// Copy Local image (Resample)
imagecopyresized//Copy Local image (resize)

2. Draw//Drawing

A.point//Point

Imagesetpixel//Draw points

B.line//Line

Imageline//Draw segment Imagearc//Draw Ellipse
arc
imagefilledarc//Draw ellipse arc and fill
imagedashedline/Draw dotted line

C.graph//Graphics

Imageellipse//Draw ellipse
imagefilledellipse//Draw ellipse and fill imagerectangle//Draw Rectangle
imagefilledrectangle//Draw
Rectangle and fill
Imagepolygon//Draw polygon
Imagefilledpolygon//Draw polygon and fill

D.text//Text

Imagechar//Reprint character (horizontal)
Imagecharup//Reprint character (vertical)
imagestring//Draw string (horizontal)
Imagestringup//Draw string (vertical)
Imagettftext//Draw text (TrueType font)
Imagefttext//Draw text (FreeType2 font)
Imagepstext//Draw text (PostScript Type1 font)

E.fill//Fill

Imagefill//Fill Color
imagefilltoborder//fill to boundary

3. Color/Colour

Imagecolorallocate//Generate color
imagecolorallocatealpha//Generate color (additional transparency)

4. Attrs//property

GetImageSize//Get image size
getimagesizefromstring//Get URL or path corresponding image size
image_type_to_extension//Get file Format (extension)
Image_type_to_mime_type//Get the MIME type of the file
Imagecolorat//Get the color of a pixel
imagefontwidth//Get the font width
Imagefontheight//Get font height
imagesx//Get image width
imagesy//Get Image Height

5. Show//output (display) image

A.convert

Image2wbmp//Convert to wbmp format and output
jpeg2wbmp//convert JPEG to wbmp format and output
png2wbmp//convert PNG to wbmp format and output

B.show

IMAGEGD//Output image (GD) imageGD2//
output image (GD2) imagegif//Output
image (GIF) imagejpeg//
output image (JPEG)
imagepng// Output image (PNG)
imagewbmp//Output image (WBMP)
IMAGEXBM//Output image (XBM)

6. Destroy//Destruction

Imagedestroy//Destroy image

More about PHP Interested readers can view the site topics: "PHP GD library Operation tips Summary", "PHP graphics and pictures Operating skills summary", "PHP basic Grammar Introductory Course", "PHP Operations and Operator Usage Summary", "PHP object-oriented Programming Program", " PHP Network Programming skills Summary, "PHP array Operation techniques Encyclopedia", "PHP string (String) Usage Summary", "Php+mysql database operations to get Started" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design.

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.