now what I am doing,
rem extract #00FF00, other as white
convert input.png -fill white +opaque "#00FF00" temp1.png
rem extract #FFFFD5, other as white
convert input.png -fill white +opaque "#FFFFD5" temp2.png
rem make it transparent
convert temp1.png -transparent white temp1_transp.png
convert temp2.png -transparent white temp2_transp.png
rem make 2 transparent png together
composite temp1_transp.png temp2_transp.png temp3.png
rem make the transparent white
convert temp3.png -background white -flatten result.png
can it do it in a single command ? because I need tens of colors and my code is not quite scalable, and skip the creation of temp image.
thanks.
extract colors from one image, other as white
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: extract colors from one image, other as white
What is your platform? From "rem", perhaps it is Windows BAT. If not, you will need to adjust this. Untested.
I think that "-fill white +opaque "#FFFFD5" -transparent white" can be simplified to "+transparent #FFFFD5".
Code: Select all
convert ^
input.png ^
( -clone 0 ^
-fill white +opaque "#FFFFD5" ^
-transparent white ^
) ^
( -clone 0 ^
-fill white +opaque "#00FF00" ^
-transparent white ^
) ^
-delete 0 ^
-composite ^
-background white -flatten ^
result.png
snibgo's IM pages: im.snibgo.com
Re: extract colors from one image, other as white
working and great, thanks