pouncer Posted April 10, 2007 Share Posted April 10, 2007 <? /* We need this in order to return a picture */ header ("Content-type: image/png"); $graph_data = array( "question" => "Rating for this item" , "1" => 82 , "2" => 18, "3" => 0, "4" => 0, "5" => 0 ); $im = ImageCreate(400, 160); $background_color = imagecolorallocate($im, 200, 200, 200); $text_color = imagecolorallocate($im, 233, 14, 91); $bar_color = imagecolorallocate($im, 0, 0, 0); $bar_color_fill = imagecolorallocate($im, 150, 150, 255); imagefill($im, 0, 0, $background_color); ImageString ($im, 5, 95, 5, $graph_data["question"], $text_color); for ($i = 1; $i <= 5; $i++) { $space = $i * 80 - 50; $text = $i . ": " . $graph_data[$i] . "%"; ImageString ($im, 2, $space, 130, $text, $text_color); } for ($i = 1; $i <= 5; $i++) { $x1 = $i * 80 - 50; $bar_height = 120 - $graph_data[$i]; $bar_width = $x1 + 20; imagerectangle($im, $x1, $bar_height, $bar_width, 120 ,$bar_color); imagefill($im, $x1, 120, $bar_color_fill); } echo imagepng($im); ?> it shows the image in the top left corner. how do i get it to show in the centre of the page? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Share Posted April 10, 2007 replace echo imagepng($im); with echo "<div align=\"center\">" . imagepng($im); . "</div>"; Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 10, 2007 Author Share Posted April 10, 2007 desn't put it in the middle for me mate? did you test it? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Share Posted April 10, 2007 hmm... well... sorry m8... never worked with dynamic pictures before... and i havent been sleeping for over 3+ hours... so my head is kinda processing info really slow at the moment Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 10, 2007 Author Share Posted April 10, 2007 it outputs a chart, but cant get it to go centre http://img368.imageshack.us/my.php?image=picur2.jpg Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Share Posted April 10, 2007 yeah i saw that... i had to upload it to a server first... my local php setup aint supporting the imagecreate() i think... need to figure out what to enable to make that work =) i'm just trying to look through it to see if i can figure something out... but as i said when i added my last post... been awake for more than 30 hours now and also i've never worked with imagecreate() Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 10, 2007 Author Share Posted April 10, 2007 ah i see. any other ideas about the alignment m8? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 10, 2007 Share Posted April 10, 2007 not at the moment... currently going through every image function on php.net you might wanna read this: http://no.php.net/manual/en/function.getimagesize.php (go trough all the codes on left side) unless an more experienced person can help you out... Quote Link to comment Share on other sites More sharing options...
pouncer Posted April 10, 2007 Author Share Posted April 10, 2007 i guess i could just change the x,y of the $im Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.