This example shows how to add random bar chart on image in php gd.
This example shows how to add random bar chart on image in php gd.<?php
Header(
"Content-type: image/jpeg"); $im = imagecreatefromjpeg( "images.jpg");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);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