gd common function
as imagecreatetruecolor () returns an image identifier, representing a size x_size
and a y_size
black image.
After a successful return to image resources, failed to return after FALSE
$image
, int $red
, int $green
, int $blue
)
$image
, int $x
, int $y
, int $color
)
image
coordinates of the image x
, y
(top left is 0, 0) with the color
color area fills performed (i.e., x, y point of the same color and adjacent dots will be filled)
$image
, int $x1
, int $y1
, int $x2
, int $y2
, int $color
)
In image
the image drawing with a color
filled rectangle of color, which is the upper-left coordinates x1
, y1
bottom-right corner coordinates x2
, y2
. 0, 0 is the most upper-left corner of the image.
$image
, int $cx
, int $cy
, int $width
, int $height
, int $color
)
Draw an ellipse on the specified coordinates.
$image
, int $cx
, int $cy
, int $width
, int $height
, int $color
)
Videos and filled into a specified ellipse image
.
$image
[, string $filename
] )
imagepng () GD image stream ( image
) output PNG format to the standard output (usually the browser),
If a filename
given file name will be output to the file.
<?php
$im = imagecreatefrompng("test.png");
imagepng($im);
?>
image
memory associated with it.
$filename
[, Array &$imageinfo
]) to obtain image size
$image
, int $cx
, int $cy
, int $width
, int $height
, int $start
, int $end
, int $color
, int $style
)
$image
, int $font
, int $x
, int $y
, string $s
, int $col
)
the imagestring () with col
the color string s
drawn to the image
image represented x
, y
at coordinates (This is the string left corner, the upper left corner of the entire image is 0,0). If you font
are 3, 4 or 5, use the built-in font.
$image
, int $x1
, int $y1
, int $x2
, int $y2
, int $color
)
imageline () with a color
color image image
from the coordinates x1
, y1
the x2
, y2
(top left is 0, 0) to draw a line segment.
Specified image
draw an elliptic arc and a filler.
<?php
header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>
<? PHP header ( "Content-of the type: Image / PNG" ); // create a canvas $ img = as imagecreatetruecolor (800, 600 ); // add color $ Blue = imagecolorallocate ( $ img , 0, 0, 255);
ImageFill ( $ IMG , 0, 0, $ Blue ); // fill color // / ImageFill (IMG $, 0, 0, $ Blue); $ Red = imagecolorallocate ( $ IMG , 255, 0, 0 ); // add filled fill effects $ Green = imagecolorallocate ( $ IMG , 0, 255, 0 ); // draw an arc // imagearc ($ IMG, 400, 300, 300, 300, 270, 0, $ Green); // draw a circular arc and fill color / * 1IMG_ARC_PIE 2.IMG_ARC_CHORD 3.IMG_ARC_NOFILL 4.IMG_ARC_EDGED IMG_ARC_PIE are mutually exclusive and IMG_ARC_CHORD ; IMG_ARC_CHORD except that a line connecting the start and end points, IMG_ARC_PIE circular boundary is generated. IMG_ARC_NOFILL specified arc or chord profile only, not filling. IMG_ARC_EDGED with straight lines indicate start and end points to the center point, and the I MG_ARC_NOFILL used with the method of drawing a pie chart is a good profile (without filling). * / // ImageFill filling if it is circular or circular inner populates filled circular external addition to location according // 600 300 $ Gray = imagecolorallocate ( $ IMG , 0xC0, 0xC0, 0xC0 ); $ DarkGray = imagecolorallocate ( IMG $ , 0x90, 0x90, 0x90 ); $ Navy = imagecolorallocate ($ IMG , 0x00, 0x00, 0x80 ); $ darknavy = imagecolorallocate ( $ IMG , 0x00, 0x00, 0x50 ); $ Red = imagecolorallocate ( $ IMG , 0xFF, 0x00, 0x00 ); $ darkred = imagecolorallocate ( $ IMG , 0x90, 0x00, 0x00 ); for ( $ I = 300; $ I > 250; $ I - ) {
// draw resources oval, x-axis semimajor axis y color semiminor the ImageFilledArc ( $ IMG , 400, $ I , 400, 350, 0, 45, $ DarkGray , 0 ); the ImageFilledArc ( $ IMG , 400, $ I , 400, 350, 45, 270,darkred $ , 0 ); the ImageFilledArc ( $ IMG , 400, $ I , 400, 350, -90, 0, $ darknavy , 0 ); }
// here drawn first with a relatively dark color such shadow effect can have the ImageFilledArc ( $ IMG , 400, 250, 400, 350, 0, 45, $ Gray , 0 ); the ImageFilledArc ( $ IMG , 400, 250, 400, 350, 45, 270, $ Red , 0 ); the ImageFilledArc ( $ IMG , 400, 250, 400, 350, -90, 0, $ Navy , 0 );
// bright colors draw imagepng ( $ img );
// png format to output images to the browser imagedestroy (img $ );
// destroy image resources
effect:
Security Code:
? < PHP $ IMG = as imagecreatetruecolor (200 is, 50 ); $ STR = "ABCDEFG" ; $ F = imagecolorallocate ( $ IMG , 0, 0, 0 ); ImageFill ( $ IMG , 0, 0, $ F ); $ S = str_shuffle ( $ STR ); // disrupt into unordered array for ( $ I = 0; $ I <. 4; $ I ++ ) { $ C = substr ( $ STR , RAND (0, strlen ( $ S ) ), 1 ); $ Color = imagecolorallocate($img, 50, 50, 50); imagestring($img, 6, 10+$i*40, rand(10,30), $c, $color); imageline($img, rand(0,30), rand(0,50), rand(150,200), rand(0,50), $color); } $color = imagecolorallocate($img, 0, 0, 255); header("Content-type:image/png;charset=utf8"); imagepng($img); imagedestroy($img);
Renderings: