English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

hi all,

I m doing a polling in php. so i need to draw the images in some bar chart like images. but i dont know how to draw the images using gd library. do anyone have any idea of drawing an image using php ?

thanks..

2006-08-08 21:50:11 · 5 answers · asked by sathesh 1 in Computers & Internet Programming & Design

5 answers

you don't need to draw the images in a barchart, you just need to have abasic blank same colour gif image and (if the chart is vertical) set the height of the image at the percentage of the votes cast.

So if you are showing each column, they would be expressed as:

"); ?>

where $percent is a number.

2006-08-08 22:00:52 · answer #1 · answered by kenhallonthenet 5 · 0 1

if you have the gd lib enabled this should work:

$width=16;
$height=16;

// Create a blank image
$image=imagecreate ($width, $height);
/**
* Define the colors that are gonna be used.
* Note: the first color allocated automaically becomes the
* background image
*/
$white=imagecolorallocate ($image, 255, 255, 255);
$black=imagecolorallocate ($image, 0, 0, 0);
$red=imagecolorallocate ($image, 255, 0, 0);
$green=imagecolorallocate ($image, 0, 255, 0);
$blue=imagecolorallocate ($image, 0, 0, 255);

// Draw whatever you like... (check the manual for more drawing functions)
// Line...
imageline ($image, 0, 0, 16, 16, $blue);
// Circle...
imagearc ($image, 0, 0, 16, 16, 0, 360, $red);

//Output the image as PNG
header ("Content-type: image/png");
imagepng ($image);

?>

Save it (image.php for example) and now you can use it as src for an image tag:



What's great is that you can even pass a query string to image.php to create dynamic images =)

2006-08-08 22:32:03 · answer #2 · answered by muoreh 2 · 0 0

basically create a picture the size you decide on yet no longer from jpeg, use imagecreatetruecolor to make the objective merchandise. the image type has scale and replica strategies to try this like imagecopymerge which you will discover very sensible. imagettftext will upload the textual content textile.

2016-09-29 02:03:58 · answer #3 · answered by ? 4 · 0 0

Since you need a chart rather than just any image, you might consider using jpGraph:

http://www.aditus.nu/jpgraph/

2006-08-09 06:25:14 · answer #4 · answered by NC 7 · 0 0

This Link will help you my friend

http://www.google.co.uk/search?hl=en&q=php+image+creating&btnG=Search&meta=

2006-08-08 22:00:50 · answer #5 · answered by Joe_Young 6 · 0 0

fedest.com, questions and answers