Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set any white pixels to transparent in ImageMagick using a threshold?

Tags:

imagemagick

Using ImageMagick, I want to find any pixels that are white and make them transparent. I'm thinking the key is -threshold but I can't work out how to change a white pixel to transparent using -threshold. Any suggestions most appreciated.

like image 294
ImageQ Avatar asked Dec 09 '10 01:12

ImageQ


2 Answers

convert input.png -fuzz 10% -transparent white output.png

Note that the order of the arguments is important - -fuzz must come before -transparent.

like image 169
Brad Avatar answered Nov 19 '22 17:11

Brad


Would something like this work?

convert input.jpg -fuzz 5% -fill to_color -opaque from_color output.jpg
like image 42
Mech Avatar answered Nov 19 '22 18:11

Mech