-entropyman Posted August 14, 2008 Share Posted August 14, 2008 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 More sharing options...
DarkWater Posted August 14, 2008 Share Posted August 14, 2008 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 More sharing options...
-entropyman Posted August 14, 2008 Author Share Posted August 14, 2008 So are you saying it is impossible to do what I am trying to do? And thank you for the quick reply Link to comment https://forums.phpfreaks.com/topic/119584-imagecolorexact-help/#findComment-616114 Share on other sites More sharing options...
DarkWater Posted August 14, 2008 Share Posted August 14, 2008 You want to see if a specific color is in an image? I'll check if there's a way other than looping through every pixel (slow). Link to comment https://forums.phpfreaks.com/topic/119584-imagecolorexact-help/#findComment-616118 Share on other sites More sharing options...
-entropyman Posted August 14, 2008 Author Share Posted August 14, 2008 That's exactly what I would like to do Link to comment https://forums.phpfreaks.com/topic/119584-imagecolorexact-help/#findComment-616122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.