Can someone help me with a simple script to replace a specific color with another color in an image using PHP?
Here is a example (color changed from green to yellow).


Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you meant using GD library in PHP, you should give a check on imagefilter()
Steps are:
imagefilter($img, IMG_FILTER_COLORIZE, 0, 255, 0))Where 0,255,0 is your RGB color (bright green in this example)Edit, Working code and clarification.
I meant, using alpha for OUTER of the black lines, and white INSIDE. Here’s the sample image:

And here’s a working code for colorizing white parts:
Note: We must negate values since colorize only works for non-white parts. We could have a workaround to this by having white-bordered image with black inside.
Note: This code only works for black-border and white-inner images.