Using PHP you can replace each pixel color one to another. Just replace your image source path and RGB color below code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
$source_file="test.png"; $from_color['r']="253"; $from_color['g']="237"; $from_color['b']="203"; $to_color['r']="0"; $to_color['g']="0"; $to_color['b']="0"; $imgsize = getimagesize($source_file); $mime = $imgsize['mime']; switch ($mime) { case 'image/gif': $image_create = "imagecreatefromgif"; $image = "imagegif"; break; case 'image/png': $image_create = "imagecreatefrompng"; $image = "imagepng"; $quality = 7; break; case 'image/jpeg': $image_create = "imagecreatefromjpeg"; $image = "imagejpeg"; $quality = 80; break; default: return false; break; } $im = $image_create($source_file); imageAlphaBlending($im, true); imageSaveAlpha($im, true); imagetruecolortopalette($im,false, 255); $index = imagecolorclosest ( $im,$from_color['r'],$from_color['g'],$from_color['b']); // get White COlor imagecolorset($im,$index,$to_color['r'],$to_color['g'],$to_color['b']); // SET NEW COLOR header('Content-Type: image/png'); $image($im); |
More Stories
CPU & Memory usage in PHP
Install PHP mcrypt extension on Ubuntu
Text to speech