RE: [PHP] sample code snippets writing text to images?

From: Date: Sat, 21 Jul 2001 05:24:52 +0000
Subject: RE: [PHP] sample code snippets writing text to images?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58997@lists.php.net to get a copy of this message
Thanks for the example, Thiago. This raises another question, however. I noticed that the code below sends the header after the HTML tag, which (if I understand correctly) requires a special setting in the php.ini file. Assuming I don't have access to that file, is there a way to work around this or to toggle that setting on a page-by-page basis? Thanks. --kurt > -----Original Message----- > From: Thiago Locatelli da Silva [mailto:thiagols@terra.com.br] > Sent: Friday, July 20, 2001 10:13 PM > To: php-general@lists.php.net > Subject: Re: [PHP] sample code snippets writing text to images? > > > <html> > test.php > > <head> > <title>PHP - button</title> > </head> > > <body> > <img src="button.php?fg=990000&bg=ffffff&txt=button one" > border="0"><br> > <img src="button.php?fg=990000&bg=ffffff&txt=button two" > border="0"><br> > </body> > </html> > > button.php > > <? > /* > image font counter > icount.php3 / by Hunje Cho (vishnu76@dreamwiz.com) > > $bgColor : Background Color , Hexadecimal > $fgColor : Foreground Color , Hexadecimal > Hexadecimal order : RGB (each 2byte) > */ > define("COUNT_FILE", "count.txt"); > define("COUNT_FONT", "2"); > > function ConvertColor($hexVal) > { > $ColorVal = array(3); > for($i = 0; $i < 3; $i++) > $ColorVal[$i] = HexDec(substr($hexVal, $i * 2, 2)); > return $ColorVal; > } > > function addCount() > { > $fp = fopen(COUNT_FILE, "r"); > $count = fgets($fp, 10); > fclose($fp); > $count++; > $fp = fopen(COUNT_FILE, "w"); > fputs($fp, $count , 10); > fclose($fp); > return $count; > } > $strCount = addCount(); > $width = strlen($strCount) * ImageFontWidth(COUNT_FONT); > $hImg = ImageCreate($width, ImageFontHeight(COUNT_FONT)); > list($red, $green, $blue) = ConvertColor($bgColor); > $clrBg = ImageColorAllocate($hImg, $red, $green, $blue); > list($red, $green, $blue) = ConvertColor($fgColor); > $clrFg = ImageColorAllocate($hImg, $red, $green, $blue); > ImageFill($hImg, 1, 1, $clrBg); > ImageString($hImg, COUNT_FONT, 1, 1, $strCount, $clrFg); > header("Content-type: image/gif"); > ImageGIF($hImg); > ImageDestroy($hImg); > ?> > > Regards > thiago >

« previous php.general (#58997) next »