Home Tutorial Php Phpgd PHP GD graphics

 
 

PHP GD graphics
Posted on: November 7, 2009 at 12:00 AM
Advertisement
This example shows how to display graphics in php gd.

<?php

$img = imagecreate(250,80);

$black = imagecolorallocate($img, 0, 0, 0);

$white = imagecolorallocate($img, 255, 255, 255);

$red = imagecolorallocate($img, 255, 0, 0);

$green = imagecolorallocate($img, 0, 255, 0);

$blue = imagecolorallocate($img, 0, 0, 255);

$corners = array(

0 => 190,

1 => 60,

2 => 210,

3 => 20,

4 => 230,

5 => 60,

);

imagerectangle($img, 10, 10, 240, 70, $white);

imagefilledrectangle($img, 20, 20, 60, 60, $red);

imagefilledellipse($img, 90, 40, 40, 40, $blue);

imagefilledellipse($img, 150, 40, 70, 40, $green);

imagefilledpolygon($img, $corners, 3, $white);

header ("Content-type: image/jpeg");

imagejpeg($img);

imagedestroy($img);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP GD graphics:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 7, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com