Home Tutorial Php Phpgd PHP GD random bar chart on image

 
 

Share on Google+Share on Google+
PHP GD random bar chart on image
Posted on: November 11, 2009 at 12:00 AM
Advertisement
This example shows how to add random bar chart on image in php gd.

<?php

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

$im = imagecreatefromjpeg( "images.jpg");

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

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

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

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

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

$x=imagesx($im);

$y=imagesy($im);

srand(mktime());

$v=rand(); $v=$v/32768*200;

ImageFilledRectangle($im,10,200-$v,60,200,$red);

$v=rand(); $v=$v/32768*200;

ImageFilledRectangle($im,70,200-$v,120,200,$green);

$v=rand(); $v=$v/32768*200;

ImageFilledRectangle($im,130,200-$v,180,200,$blue);

$v=rand(); $v=$v/32768*200;

ImageFilledRectangle($im,190,200-$v,240,200,$yellow);

$v=rand(); $v=$v/32768*200;

ImageFilledRectangle($im,250,200-$v,300,200,$cyan);

Imagejpeg($im);

ImageDestroy($im);

?>

After running the program you will get the following output

Advertisement

Related Tags for PHP GD random bar chart on image:


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

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com