php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19781 ImageTrueColorToPalette() ignores color parameter
Submitted: 2002-10-06 12:18 UTC Modified: 2002-10-06 12:56 UTC
From: sprice at wisc dot edu Assigned:
Status: Closed Package: GD related
PHP Version: 4CVS-2002-10-06 OS: Darwin 6.1 (Mac 10.2.1)
Private report: No CVE-ID: None
 [2002-10-06 12:18 UTC] sprice at wisc dot edu
imagetruecolortopalette() is:
void imagetruecolortopalette ( resource image, bool dither, int ncolors)

but the function seems to ignore my ncolors input. ncolors  should be the maximum number of colors in the output image. (and I cannot tell if dither works)

Test script:
<?php
header( "Content-type: image/png" );

$medimg = $_SERVER['DOCUMENT_ROOT'] . "/riverdata/images/world_map_med.gd2";
$img = ImageCreateFromGD2Part( $medimg, 900, 500, 800, 600 );

//Avoid bug #19418
$medimg = ImageCreateTrueColor( 800, 600 );
ImageCopy( $medimg, $img, 0, 0, 0, 0, 800, 600 );
ImageDestroy( $img );
$img = $medimg;

ImageTrueColorToPalette( $img, FALSE, 2 );

ImagePNG( $img );
ImageDestroy( $img );
?>

You can find the GD2 image that I am using here:
http://144.92.10.251/riverdata/images/world_map_med.gd2

The previous episode in this saga can be seen here:
http://bugs.php.net/bug.php?id=19704

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-06 12:30 UTC] rasmus@php.net
Is world_map_med.gd2 a truecolor image?  This function does nothing if the image has a palette.
 [2002-10-06 12:40 UTC] sprice at wisc dot edu
If it wasn't before it is converted to true color in the script.
 [2002-10-06 12:52 UTC] rasmus@php.net
Ok, I traced through this one quickly.  It does convert the image from truecolor to palette based, it just happens to choose 234 colours instead of 2.  I'll take a look at this later on today.
 [2002-10-06 12:56 UTC] rasmus@php.net
Ok, fixed in CVS.  Someone hardcoded 256 into this function.  Looks like nobody ever actually tested this one.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 11:01:31 2024 UTC