How to convert colours to black in images using ImageMagick

Robin ScottLinux Tutorials0 Comments

If you want to convert PNG (or similar) files containing, for example, icons which are in one colour (say green) to black, then the command below will do this.

Note you will need ImageMagick installed on your server (the commands involved for doing that will vary from environment to environment – Google it! – for example “install imagemagick on AWS linux” or whatever).

convert oldfilename.png -negate -threshold 0 -negate newfilename.png

These instructions use the Threshold instruction to turn ANYTHING that isn’t white into black.

More info here.

Leave a comment below if this helped you solve your problem – ImageMagick commands are sometimes hard to come by!

Leave a Reply

Your email address will not be published. Required fields are marked *