Home Tutorial Php Phpgd PHP GD Draw Rectangle

 
 

Share on Google+Share on Google+
PHP GD Draw Rectangle
Posted on: November 4, 2009 at 12:00 AM
Advertisement
This example shows how to draw rectangle in php gd.

<?php

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

$width = 350;

$height = 360;

$im = ImageCreateTrueColor($width, $height);

ImageAntiAlias($im, true);

$white = ImageColorAllocate($im, 255, 255, 255);

ImageFillToBorder($im, 0, 0, $white, $white);

$black = ImageColorAllocate($im, 0, 0, 0);

$blue = ImageColorAllocate($im, 0, 0, 255);

$r_width = 140;

$r_height = 90;

$r_x = 90;

$r_y = 40;

ImageRectangle($im, $r_x, $r_y, $r_x+$r_width, $r_y+$r_height, $black);

$r_width = 140;

$r_height = 90;

$r_x = 90;

$r_y = 180;

ImageFilledRectangle($im, $r_x, $r_y, $r_x+$r_width, $r_y+$r_height, $blue);

ImageJPEG($im);

ImageDestroy($im);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP GD Draw Rectangle:


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 4, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com