Page 1 of 1

How to get color edges when using -fill?

Posted: 2020-05-20T23:14:01-07:00
by etrader
I convert a transparent PNG to black with

Code: Select all

convert 1.png -channel RGB -fill Black -colorize 100 +channel -blur 1x8 -background white -flatten 2.png 
Image
Image

How can I turn the colour edges (for example, around eyes or face/mask lines) into white or transparent lines while the whole shape has been filled to be black?

Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org (Ubuntu)

Re: How to get color edges when using -fill?

Posted: 2020-05-21T03:22:57-07:00
by snibgo
There are many possibilities. For example, using "-edge", bash script:

Code: Select all

convert \
  face1.png \
  \( +clone \
     -alpha off \
     -edge 1 \
     -fill White +opaque Black \
     -transparent Black \
     +write e.png \
     +write mpr:EDGES \
  \) \
  -channel RGB -fill Black -colorize 100 +channel \
  -blur 1x8 -background white -layers flatten \
  mpr:EDGES \
  -layers flatten \
  face2.png 
Image