How to get color edges when using -fill?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Posts: 21
Joined: 2012-09-29T06:53:04-07:00
Authentication code: 67789

How to get color edges when using -fill?

Post 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 

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 (Ubuntu)

Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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 \
snibgo's IM pages: