php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12963 ImageColorAllocate() doesn't work with PNGs
Submitted: 2001-08-26 06:01 UTC Modified: 2001-10-02 19:11 UTC
From: perry at globalnet dot co dot uk Assigned:
Status: Closed Package: GD related
PHP Version: 4.0.6 OS: Windows95
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: perry at globalnet dot co dot uk
New email:
PHP Version: OS:

 

 [2001-08-26 06:01 UTC] perry at globalnet dot co dot 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-26 06:35 UTC] mathieu@php.net
I'm not a PNG expert but you could try ImageColorResolve() 
The palette used in 'basic.png' may be different than you
expect.

 [2001-08-27 18:09 UTC] wez@php.net
PHP 4.0.6 on win32 uses GD 2.0.1 BETA.
It is broken for palette based PNG images; you
need to use a different version of GD, or wait for PHP 4.0.7.

--Wez.
 [2001-10-02 19:11 UTC] sniper@php.net
Not really a PHP bug. But will be fixed for 4.0.7 (which will use older and working GD libraries)
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 17 16:05:45 2022 UTC