I have the input image shown below. I'm trying to add around it a rounded edge.
I've tried with the command below and adds a border but without rounded corners
convert input.jpg -shave 1x1 -bordercolor white -border 10 output.jpg
The image below shows what I'd like to get as output. How can I do this effect in IM7?
They closed my previous question since they found duplicated and mentioned the answer is in this thread, but in that thread there is no solution for my question, since only adds rounded corners to an image but without an edge.
UPDATE
I've found this solution done by @MarkSetchell in this thread. I see it works pretty fine with black border, but If I try to replace the first -fill black
and xc:black
with -fill white
and xc:white
then the internal corners remains with an angle of 90 degrees and not rounded like it looks when the border is black in the original command.
#!/bin/bash
# Get width and height of input image
read iw ih < <(identify -format "%w %h" monsters.jpg)
# Calculate size of output image, assumes thickness=10
((ow=iw+20))
((oh=ih+20))
magick -size ${ow}x${oh} xc:none -fill black -draw "roundrectangle 0,0 $ow,$oh 20,20" \
\( -size ${iw}x${ih} xc:black -fill white -draw "roundrectangle 0,0,$iw,$ih 20,20" input.png -compose darken -composite \) \
-gravity center -compose over -composite result.png
If you want the border white, you'll need to swap black and white in my original answer, and then choose the "lighten" blend mode to choose the lightest pixel at each location:
#!/bin/bash
# Get width and height of input image
read iw ih < <(identify -format "%w %h" yosemite.png)
# Calculate size of output image, assumes thickness=10
((ow=iw+20))
((oh=ih+20))
magick -size ${ow}x${oh} xc:none -fill white -draw "roundrectangle 0,0 $ow,$oh 20,20" \
\( -size ${iw}x${ih} xc:white -fill black -draw "roundrectangle 0,0,$iw,$ih 20,20" yosemite.png -compose lighten -composite \) \
-gravity center -compose over -composite result.png