Search code examples
phpimagickgd2

How to isolate only one colour on image with PHP?


Is it possible to leave (isolate) only one colour in image? Currently I'm interested in green:005d00


Solution

  • Well you can do it using ImageMagick via the command line:

    convert original.png -matte ( +clone -fuzz 1 -transparent #005d00 ) -compose DstOut -composite isolated.png
    

    The -fuzz command can take a percentage variance from the colour, if it's specific, drop the fuzz.

    The () brackets need escaping in bash shell \( \), etc.