Drawing graphic lines using PHP GD SupportIf you have installed GD library then let us try to draw some lines in an image using gd support. We will open our file in a new window as we have to tell browser ( through header ) that we are sending image.
Using gd we will first learn how to draw line. We will learn some basic functions used in creating and managing images.
$im = @ImageCreate (100, 200)The above line creates and image identifier of width 100 and height 200. The top left coordinate is set as 0, 0
$background_color = ImageColorAllocate ($im, 234, 234, 234);Background color is set here for the image with the identifier $im. Here we have set it to a light gray background. The color of the background can be changed by changing the values of red, green, blue ( now all are set to 234 to create light gray background)
Same way let us set a text color for the image
$text_color = ImageColorAllocate ($im, 233, 14, 91);
The above line will show the line from where to where it is to be drawn. Staring from $x1,$x2 to $x2, $y2. Note that top left is at the coordinate 0,0. The lines below will give how the line will appear with different values of the coordinates used in imageline function.
| imageline ($im,0,0,100,200,$text_color);|
Be the first to post comment on this article :
|GD functions in PHP for handling images & graphics|
How to check GD support in PHP |
Header for an image in browser
Drawing of graphic lines using GD
Plotting line graph by drawing data from table
Adding vertical grid to line graph
Resizing and adding border to Images
Script for Watermarking image on the fly using PHP GD
Script to generate Captcha using GD with demo
Getting Image coordinates ( vertical and horizontal ) of points inside a image
Page Hit counter script