How to colorize a black-transparent PNG icon with ImageMagick
You can use one of the following commands:
$ convert input.png +level-colors "red", output.png
$ convert input.png +level-colors "rgb(255,0,0)", output.png
$ convert input.png +level-colors "#ff0000", output.png
Note that the ,
character is important here. On the left side of the ,
character we tell convert
which color should replace black and on right side what color should replace white. Therefore nothing should be given after the ,
character.
Source
... how do I colorize black & transparent PNG images [...] to colorize them like this [...] using ImageMagick
The -fill <COLOR>
option works fantastic for this purpose. You can replace "#1bbfc9"
with a human-readable name (e.g. "red") or an HTML color code.
convert target-black.png -fill "#1bbfc9" -colorize 100 target-blue.png
... allowing to script and process hundreds of icons at a time
Using the find
command, you can recurse hundreds.
Warning: This will replace the originals.
find path/to/files -iname '*.png' -exec convert "{}" -fill "#1bbfc9" -colorize 100 "{}" \;