Demonic Posted March 28, 2008 Share Posted March 28, 2008 <?php //cleanscript.com 2008 $image = "smiley.png"; $data = getimagesize($image); $width = intval($data[0]); $height = intval($data[1]); $cloneH = 0; $hex = "FF0000"; $oldhex = "FCFF00"; $im = imagecreatefrompng($image); $color = imagecolorallocate($im,hexdec(substr($hex,0,2)),hexdec(substr($hex,2,2)),hexdec(substr($hex,4,6))); for($cloneH=0;$cloneH<$height;$cloneH++) { for($x=0;$x<$width;$x++) { if( colormatch($im,$x,$cloneH, $oldhex) ) imagesetpixel($im, $x, $cloneH, $color); } } header("Content-Type: {$data['mime']}"); imagepng($im); function colormatch($image,$x,$y,$hex) { $rgb = imagecolorat($image,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF; $r2 = hexdec(substr($hex,0,2)); $g2 = hexdec(substr($hex,2,2)); $b2 = hexdec(substr($hex,4,6)); if( $r == $r2 && $b == $b2 && $g == $g2 ) return true; return false; //echo "$r $r2, $g $g2, $b $b2"; } ?> Example: http://nbbmodbase.krawp.com/imagecolorswitch/ How can I like make it not fuzzy on the edges and the image completely changes its color? Quote Link to comment https://forums.phpfreaks.com/topic/98414-alright-i-got-an-image-and-ive-changed-the-color-its-fuzzy/ Share on other sites More sharing options...
MadTechie Posted March 29, 2008 Share Posted March 29, 2008 try using a gif Quote Link to comment https://forums.phpfreaks.com/topic/98414-alright-i-got-an-image-and-ive-changed-the-color-its-fuzzy/#findComment-503705 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.