Filter for a fuzzy border?

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?".
Post Reply
AliceWonder
Posts: 11
Joined: 2014-07-09T21:41:34-07:00
Authentication code: 6789

Filter for a fuzzy border?

Post by AliceWonder »

In The GIMP - I can open an image, in the Decor menu there is a "fuzzy border" filter.

You can specify a color, the border size, how much blur there is, whether or not to add a shadow.

When I look what it does, it creates a layer that is transparent in the middle, and has a border of specified color and dimension but is "fuzzy" on the inside edges of the border. I never use the drop shadow feature.

How do I do the same in ImageMagick from command line? It seems like it is probably straight forward, but I haven't found the syntax on http://www.imagemagick.org/Usage/crop/ which is where Bing sends me when I search.

ImageMagick-7.0.3.9

Thanks for suggestions
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Filter for a fuzzy border?

Post by Bonzo »

User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Filter for a fuzzy border?

Post by GeeMack »

AliceWonder wrote: 2017-02-09T07:35:30-07:00You can specify a color, the border size, how much blur there is, whether or not to add a shadow. [...] I never use the drop shadow feature.
There are several ways to approach this. Using IM7 from a Windows command prompt, something like this would give you the result you describe...

Code: Select all

magick input.png -gravity center -bordercolor none ( -clone 0 -fill #804020 -colorize 100 ) ^
   ( -clone 0 -fill black -colorize 100 -shave 30 -border 30 -blur 0x8 ) -swap 0,1 -composite result.png
Inside the first parentheses it makes a copy of the input image. Then the "-fill ..." and "-colorize 100" change it to whatever you choose for a the frame color.

Inside the second parentheses it makes another copy, turns it black, shaves it to the size you want for the "hole", and blurs the edges of that. The "-shave ..." and "-border ..." operations determine the width of the frame. The "-blur ..." determines how much blur you have on the edges.

Now you have a stack of three images, the original input, the solid colored copy for the frame, and the shaved and blurred copy to use as a mask.

Next the "-swap 0,1" makes the first and second layers trade places so they're in the right order for the composite.

Finally the "-composite" lays down the frame color then the input image then the mask. The top layer, the mask, determines which part of the input image shows.

My code above is in Windows syntax. For a Unix shell you'd need to change that continued line caret "^" to a backslash "\", and probably escape all the parentheses with backslashes like "\(" and "\)", too.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Filter for a fuzzy border?

Post by fmw42 »

What is your platform? If Unix-like, then see my scripts: bordereffects, bordergrid and imageborder for other border-like effects. I do not have this one, but GeeMack has given you a command for that which can be converted to unix syntax by replacing ( ... ) with \( ... \) and his new line ^ with \
AliceWonder
Posts: 11
Joined: 2014-07-09T21:41:34-07:00
Authentication code: 6789

Re: Filter for a fuzzy border?

Post by AliceWonder »

Thanks. Yes I am on *nix, will be trying it shortly.
Post Reply