Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2007-01-11, 01:26 AM
Junior Member
 
Join Date: Jan 2007
Posts: 1
christina is on a distinguished road
Default adding text on images

Hi,

May i know how to add text on imges using php.


Thanks,
Ruth
Reply With Quote
  #2 (permalink)  
Old 2007-01-11, 04:05 PM
Junior Member
 
Join Date: Jan 2007
Posts: 3
syscode is on a distinguished road
Default Somthin like this

PHP Code:
//Tell gd2, where your fonts reside 
putenv('GDFONTPATH=C:\WINDOWS\Fonts'); 
$font 'arial'

//Set starting point for drawing 
$y 50

//Specify constant values 
$width 700//Image width in pixels
$bar_height 20//Bars height
$height $num_poller $bar_height 1.5 70//Calculating image height 
$bar_unit = ($width 400) / 100//Distance on the bar chart standing for 1 unit

//Create the image resource 
$image ImageCreate($width$height); 

//We are making four colors, white, black, blue and red 
$white ImageColorAllocate($image255255255); 
$black ImageColorAllocate($image000); 
$red   ImageColorAllocate($image25500); 
$blue  imagecolorallocate($image,0,0,255); 

//Create image background 
ImageFill($image,$width,$height,$white); 
//Draw background shape 
ImageRectangle($image00$width-1$height-1$black); 
//Output header 
ImageTTFText($image160$width/50$y 20$black$font'Poll Results'); 

while (
$row mysql_fetch_object($result)) { 
  if (
$total_votes 0
    
$percent intval(round(($row->num_votes/$total_votes)*100)); 
  else 
    
$percent 0

//Output header for a particular value 
ImageTTFText($image,12,0,10$y+($bar_height/2), $black$font$row->book_type); 
//Output percentage for a particular value 
ImageTTFText($image120170$y + ($bar_height/2),$red,$font,$percent.'%'); 

$bar_length $percent $bar_unit

//Draw a shape that corresponds to 100% 
ImageRectangle($image$bar_length+221$y-2, (220+(100*$bar_unit)), $y+$bar_height$black); 
//Output a bar for a particular value 
ImageFilledRectangle($image,220,$y-2,220+$bar_length$y+$bar_height$blue); 
//Output the number of votes 
ImageTTFText($image120250+100*$bar_unit$y+($bar_height/2), $black$font$row->num_votes.' votes cast.'); 

//Going down to the next bar 
$y $y + ($bar_height 1.5); 



//Tell the browser what kind of file is come in 
header("Content-Type: image/jpeg"); 

//Output the newly created image in jpeg format 
ImageJpeg($image); 

//Free up resources 
ImageDestroy($image); 
?> 
__________________
tutorials - http://www.codpe.com
iq test - http://www.iqpe.com
some stuff - http://www.laamer.com
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:46 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.