RE: Bug #12963 Updated: ImageColorAllocate() doesn't work with PNGs

From: Date: Mon, 27 Aug 2001 18:43:44 +0000
Subject: RE: Bug #12963 Updated: ImageColorAllocate() doesn't work with PNGs
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-64427@lists.php.net to get a copy of this message
Hi, ImageColorResolve() doesn't solve it - but you will be happy to know that I did solve it - form your palette tip. Guessing that the color is not in the palette, use: imagecolorset($image,1,255,100,100); to force your color into the palette. So, this works: ********************************* <?php header ("Content-type: image/png"); $text=implode($argv," "); $image=imageCreateFromPNG("basic.png"); imagecolorset($image,1,255,100,100); $text_color=imageColorAllocate($image,255,100,100); $textX=(imageSX($image)-imageFontWidth(4)*strlen($text))/2; imageString($image,5,$textX,10,$text,$text_color); imagePNG($image); imageDestroy($image); ?> ********************************* Thanks for the help. P.S. I spotted a couple of spelling mistakes in the PHP manual. In cpdf_save and cpdf_restore, you write 'enviroment'. The correct spelling is 'environment'. (Mind you - this is English, not American'). Jon Perry perry@globalnet.co.uk jonperry@silicontoads.com http://www.users.globalnet.co.uk/~perry Brainbench 'Most Valuable Professional' for HTML Brainbench 'Most Valuable Professional' for JavaScript http://www.brainbench.com Object-Oriented Links at Cetus http://www.cetus-links.org Subscribe to Delphiadvanced: http://groups.yahoo.com/group/Delphiadvanced -----Original Message----- From: Bug Database [mailto:php-dev@lists.php.net] Sent: 26 August 2001 11:36 To: perry@globalnet.co.uk Subject: Bug #12963 Updated: ImageColorAllocate() doesn't work with PNGs ID: 12963 Updated by: mathieu Reported By: perry@globalnet.co.uk Old Status: Open Status: Feedback Bug Type: GD related Operating System: Windows95 PHP Version: 4.0.6 New Comment: I'm not a PNG expert but you could try ImageColorResolve() The palette used in 'basic.png' may be different than you expect. Previous Comments: ------------------------------------------------------------------------ [2001-08-26 06:01:52] perry@globalnet.co.uk <?php header ("Content-type: image/png"); $text=implode($argv," "); $image=imageCreateFromPNG("basic.png"); $background_color = ImageColorAllocate ($im, 100, 100, 255); $text_color=imageColorAllocate($image,255,100,100); $textX=(imageSX($image)-imageFontWidth(4)*strlen($text))/2; imageString($image,5,$textX,10,$text,$text_color); imagePNG($image); imageDestroy($image); ?> This is only a small modification of the example given in the manual, but the $text_color is always white. This works for JPEG, but the quality suffers, and my build of PHP doesn't support GIF's. ------------------------------------------------------------------------ ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=12963&edit=2

« previous php.dev (#64427) next »