Jump to content

imagecolorexact help


-entropyman

Recommended Posts

Hello,

 

Anyone have any ideas as to what i'm doing wrong?  I always return "Color exists!" even when the color does not.

 

$src = 'http://205.234.203.76/pb000004.png';
$img = imagecreatefrompng($src);
$red = '255';
$green = '0';
$blue = '0';


$ind = imagecolorexact ( $img, $red, $green, $blue );
if ( $ind != -1 )
{
	echo " The color exists! ";
}else{
	echo "Fail";
}

echo "<img src= {$src}>";

?>

 

Any help appreciated!

:)

Link to comment
https://forums.phpfreaks.com/topic/119584-imagecolorexact-help/
Share on other sites

First note on the manual page for imagecolorexact:

 

A few notes about this function...

 

This function will only work on images where the palette is 256 colors or less. You also can not use imagetruecolortopalette() to reduce the palette on a true color PNG image that has greater than 256 colors in it's palette, then call this function. If you try to do this imagecolorexact() will report colors not being in the image when they are in the image!

 

1. works on png(s) 8bit/256 colors or less.

2. works on all gif(s)

3. does not work on any type of jpg/jpeg image.

Credits:

jbr at ya-right dot com

18-Feb-2006 03:38

Link to comment
https://forums.phpfreaks.com/topic/119584-imagecolorexact-help/#findComment-616110
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.