Draw text using PHP GD,TTF fonts

For built-in GD fonts, use ImageString() php function. Example: <?php ImageString($image, 1, $x, $y, ‘THIS TEXT WILL BE SHOWN’, $text_color); ?> TrueType fonts can be used to render text as images, using ImageTTFText() php function. Example: <?php ImageTTFText($image, $size, 0, $x, $y, $text_color, ‘/path/to/font.ttf’, ‘THIS TEXT WILL BE SHOWN’); ?>
Continue reading…

Enjoyed this post? Share it!

 
 

Draw filled black circle with PHP

The ImageFillToBorder() function floods a region beginning at ($x,$y) with the color specified as the last parameter until it hits the edge of the canvas or runs into a line with the same color as the third parameter. $image = ImageCreate(100,100); $bg = ImageColorAllocate($image, 255, 255, 255); $black = ImageColorAllocate($image, 0, 0, 0); ImageArc($image, 50, […]
Continue reading…

Enjoyed this post? Share it!

 
 

Drawing Lines, Rectangles, and Polygons with PHP

The first parameter is the canvas to draw on. The next set of parameters are the x and y coordinates to specify where GD should draw the shape. In ImageLine( ), the four coordinates are the endpoints of the line, and in ImageRectangle( ), they’re the opposite corners of the rectangle. For example, ImageLine($image, 0, […]
Continue reading…

Enjoyed this post? Share it!