Draws a line between the two given points.
PHP imageline() function has the following syntax.
bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
PHP imageline() function has the following parameters.
Returns TRUE on success or FALSE on failure.
In this simple example you draw a straight line between two points, then output the resulting image to the browser.
<?php
$myImage = imagecreate( 200, 100 );
$myGray = imagecolorallocate( $myImage, 204, 204, 204 );
$myBlack = imagecolorallocate( $myImage, 0, 0, 0 );
imageline( $myImage, 15, 35, 120, 60, $myBlack );
header( "Content-type: image/png" );
imagepng( $myImage );
imagedestroy( $myImage );
?>
If you receive an undefined function imagecreate() error message on Windows, enable the GD2 extension.
Edit your php.ini file and remove the semicolon from the start of the following line:
;extension=php_gd2.dll
Restart your server after you've made this change.