Functions of the PHP GD library (i)

Source: Internet
Author: User
PHP GD Library related tutorials
1.PHP Development watermark and thumbnail tutorial
2.PHP watermark and thumbnail latest video tutorial
3.php Picture processing GD2 configuration file modification




Image_type_to_mime_type-Gets the MIME type of the image type returned by Getimagesize,exif_read_data,exif_thumbnail,exif_imagetype//$aa = GetImageSize ("./logo_i.gif");//print_r (Image_type_to_mime_type ($AA));//imagearc — Draw elliptical Arcs/*bool Imagearc (resource $image, int $cx, int $cy, int $w, int $h, int $s, int $e, int $color),//$image: Resources//$CX: Left off The position of the Center//$cy: The position of the top from the Center//$w: Round diameter around//$h: Round diameter//$s: 0 degrees clockwise Draw//$e://$color: Round color//Create a 200X200 image $img = Imagecreatetruecolor (200, 200);//Assign Color $white = imagecolorallocate ($img, 255, 255, 255); $black = Imagecolorallocate ($img , 0, 0, 0);//Draw a white round imagearc ($img, +, +,, content-type:image/png, 0, N, $white);//Output the image to the browser header (""); imag Epng ($img);//Release Memory Imagedestroy ($IMG); *///imagechar — Draw a character horizontally/*bool Imagechar (resource $image, int $font, int $x, int $y, string $c, int $color) $image: Resource $font: Font size $x: text Distance from left border $y: The distance from the top of the text $c: the first character of the string C is drawn in the image specified by $color: The color of the text $im = Imagecreate (100,100); $string = ' php '; $bg = Imagecolorallocate ($im, 255, 255, 255); $black = imagecolorallocate ($im, 0, 0, 0);//Prints a black "P" in the top left Cornerimagechar ($im, 1, 0, 0, $str ING, $black); header (' content-type:image/png '); Imagepng ($im); *///imagecharup — To draw a character vertically/*bool Imagecharup (resource $image, int $font, int $x, int $y, string $c, int $color) $image: Resource $font: Font size $x : The distance from the left border of the text $y: The distance from the top of the text $c: the first character of the string C is drawn in the image specified by $color: The color of the text $im = Imagecreate (100,100); $string = ' Note that the Firs T letter is a N '; $bg = Imagecolorallocate ($im, 255, 255, 255); $black = imagecolorallocate ($im, 0, 0, 0);//Prints a black "Z" on a white Backgroundimagecharup ($im, 3, ten, $string, $black); header (' content-type:image/png '); Imagepng ($IM); * * Imagecolorallocate — Assigns a color to an image/*int Imagecolorallocate (resource $image, int $red, int $green, int $blue) $image: Picture Resource $red, $green, $blue are required To the color of the red, green, blue ingredients. These parameters are integers from 0 to 255 or hexadecimal 0x00 to 0xFF the first call to Imagecolorallocate () fills the color palette-based image with the background color $im = imagecreate (100, 100);//Background set to red $bac Kground = ImagEcolorallocate ($im, 255, 0, 0);//Set some colors $white = imagecolorallocate ($im, 255, 255, 255); $black = imagecolorallocate ($im, 0 , 0, 0);//16 Binary $white = Imagecolorallocate ($im, 0xFF, 0xFF, 0xFF); $black = Imagecolorallocate ($im, 0x00, 0x00, 0x00); hea Der (' Content-type:image/png '); Imagepng ($im); *///imagecolorallocatealpha — Assigns a color to an image + Alpha/*int Imagecolorallocatealpha (resource $image, int $red, int $green, int $blue, int $alpha) Imageco The behavior of Lorallocatealpha () is the same as imagecolorallocate (), but with an extra transparency parameter of alpha, its value is from 0 to 127. 0 means completely opaque and 127 is completely transparent. $size = +; $image =imagecreatetruecolor ($size, $size);//Use a white background with a black border to draw a square $back = imagecolorallocate ($image, 255, 255, 255 ); $border = imagecolorallocate ($image, 0, 0, 0); Imagefilledrectangle ($image, 0, 0, $size-1, $size-1, $back); imagerecta   Ngle ($image, 0, 0, $size-1, $size-1, $border); $yellow _x =; $yellow _y = _y; $red _x = 165; $red _x = 187; $blue _y = $radius = 150;//assigns some color with alpha value $yellow = imagecolorallocateAlpha ($image, 255, 255, 0), $red = Imagecolorallocatealpha ($image, 255, 0, 0, imagecolorallocatealpha); $blue $image, 0, 0, 255, 75);//Draw three overlapping round imagefilledellipse ($image, $yellow _x, $yellow _y, $radius, $radius, $yellow); Imagefilledellipse ($image, $red _x, $red _y, $radius, $radius, $red); Imagefilledellipse ($image, $blue _x, $blue _y, $ Radius, $radius, $blue);//Don't forget to output the correct header! Header (' content-type:image/png ');//FINAL Output imagepng ($image); Imagedestroy ($image); *///imagecolordeallocate & Mdash Cancels the assignment of the image Color/*bool imagecolordeallocate (resource $image, int $color) imagecolordeallocate () function canceled previously by Imagecolorallocate () or Imagecolorallocatealpha () to assign a color. $im = imagecreate (100, 100);//Background set to red $background = Imagecolorallocate ($im, 255, 0, 0);//Set some color $white = Imagecolorallocat E ($im, 255, 255, 255) imagecolordeallocate ($im, $white); header (' content-type:image/png '); Imagepng ($im); */// Imagecolorexact — Gets the index value of the specified color/*int imagecolorexact (resource $image, int $red, int $green, int $Blue) returns the index value of the specified color in the image palette. Returns 1 if the color is not in the image's palette. If you create an image from a file, only the colors used in the image will be discriminated. Colors that appear only in the palette are not discriminated. $im = imagecreate (100, 100);//Background set to red $background = Imagecolorallocate ($im, 255, 0, 0);//Set some color $white = Imagecolorallocat E ($im, 255, 255, 255); $aa = Imagecolorexact ($im, 255, 0, 0); echo $aa;//Not present return -1*///imagecolorset — Sets the color for the specified palette index/*void imagecolorset (resource $image, int $index, int $red, int $green, int $blue) This function sets the index specified in the palette to the specified color 。 $im = Imagecreate (+), $background = Imagecolorallocate ($im, 255, 0, 0); for ($c = 0; $c


The above is the function of PHP-GD library (a) _GD library tutorial content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!


  • Related Article

    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.