Rounded Corners with 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
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Rounded Corners with border

Post by Don »

Hello,

i have the following command that applies a rounded corner to an image, but I would like it to apply a border as well. I tried to apply a border to an image first and then take the newly border image and apply the command below but the border was cut off at the corners. If I can get he below command to apply a border with rounded corners, that would be ideal.

Code: Select all

convert image.png \( +clone -alpha extract \( -size 15x15 xc:black -draw 'fill white circle 15,15 15,0' -write mpr:arc +delete \) \( mpr:arc \) -gravity northwest -composite \( mpr:arc -flip \) -gravity southwest -composite \( mpr:arc -flop \) -gravity northeast -composite \( mpr:arc -rotate 180 \) -gravity southeast -composite \) -alpha off -compose CopyOpacity -composite -compose over \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge resultImage.png
Any guidance on this would be great. Thank you in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rounded Corners with border

Post by fmw42 »

Your request is not clear. Where do you want the border and what color.

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://http://www.imagemagick.org/scrip ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/

Since the outside of your rounded corners is transparent and shadowed, you can only add the border inside the rounded corner image. So try this

Code: Select all

convert logo: \( +clone -alpha extract \
\( -size 15x15 xc:black -draw 'fill white circle 15,15 15,0' -write mpr:arc +delete \) \
\( mpr:arc \) -gravity northwest -composite \
\( mpr:arc -flip \) -gravity southwest -composite \
\( mpr:arc -flop \) -gravity northeast -composite \
\( mpr:arc -rotate 180 \) -gravity southeast -composite \) \
-alpha off -compose CopyOpacity -composite -compose over \
\( -clone 0 -fill red -colorize 100 \) \
\( -clone 0 -alpha extract -virtual-pixel black -morphology edgein octagon:10  \) \
-compose over -composite \
\( +clone -background black -shadow 80x3+5+5 \) \
+swap -background none -layers merge +repage logo_rounded_shadow.png
Image

Is that what you want?
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Rounded Corners with border

Post by Don »

Hello,

Yes that is basically what I was looking for.

I apologize if I have broken any posting rules or posted in the wrong section. You may move to the appropriate section if necessary.

IM version is: ImageMagick 6.9.5-4 Q16 x86_64 2016-08-2
Platform: Mac

The border color can be any IM color specified around the image circling complete like you have done with logo.

Thank you for your assistance. Much appreciated.
Post Reply