Round corners

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?".
kaktusyaka

Round corners

Post by kaktusyaka » 2010-06-27T15:38:13-07:00

Hi

Pleasy, help me change the angle corners to round ones

Code: Select all

convert thumbnail.gif -alpha set -compose DstOut \
        \( -size 20x10 xc:none -draw "polygon 0,0 0,9 19,0" \
           -write mpr:triangle  +delete \) \
        \( mpr:triangle             \) -gravity northwest -composite \
        \( mpr:triangle -flip       \) -gravity southwest -composite \
        \( mpr:triangle -flop       \) -gravity northeast -composite \
        \( mpr:triangle -rotate 180 \) -gravity southeast -composite \
        corner_cutoff.png
Thanks!!

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Round corners

Post by fmw42 » 2010-06-27T18:08:04-07:00


kaktusyaka

Re: Round corners

Post by kaktusyaka » 2010-06-28T01:30:14-07:00

Thanks. But I want round only top-left and bottom-right corners.

kaktusyaka

Re: Round corners

Post by kaktusyaka » 2010-06-28T01:36:26-07:00

Actually I need to round out all combinations of angles (for example: the upper left and lower right or lower right, upper right and lower left, etc.)


Thanks for your help

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Round corners

Post by fmw42 » 2010-06-28T11:01:09-07:00

create a rounded corner all around. then crop one corner and rotate appropriately and composite it over all the corners you want in your original image.

kaktusyaka

Re: Round corners

Post by kaktusyaka » 2010-06-28T11:07:08-07:00

> create a rounded corner all around. then crop one corner and rotate appropriately and composite it over all the corners you >want in your original image.

I not well in imagemagick. Can you write me example of this command?

Thanks!!!

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

Re: Round corners

Post by Bonzo » 2010-06-28T11:29:53-07:00

From a similar thread started 5 days ago!
http://www.imagemagick.org/Usage/thumbnails/#rounded

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Round corners

Post by fmw42 » 2010-06-28T11:35:47-07:00

convert thumbnail.gif \( +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 rounded_corners.png


just pick and remove which of the four -gravity lines you want to delete so as to leave the rounded corners you want

So to get only the UL and BR corners use:

convert thumbnail.gif \( +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 -rotate 180 \) -gravity southeast -composite \) \
-alpha off -compose CopyOpacity -composite rounded_corners2.png


This may not be the most efficient way, but it is one way to do it.

kaktusyaka

Re: Round corners

Post by kaktusyaka » 2010-06-28T21:54:06-07:00

Its work!!!!


The many thanks for your help!!!!!!!!

marciano
Posts: 10
Joined: 2011-06-18T15:09:09-07:00
Authentication code: 8675308

Re: Round corners

Post by marciano » 2011-06-18T15:13:33-07:00

Hello.
I get "convert: unrecognized option `-alpha'."
My version is 6.2.8.0-4.el5_5.3
How can I solve it.
I need rounded corners and a soft image shadow.
Thank you

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Round corners

Post by fmw42 » 2011-06-18T16:15:59-07:00

marciano wrote:Hello.
I get "convert: unrecognized option `-alpha'."
My version is 6.2.8.0-4.el5_5.3
How can I solve it.
I need rounded corners and a soft image shadow.
Thank you

Your version of IM is way too old (over 400 versions old). You should try to upgrade. If not, then the problem is -alpha extract is too new. So try

Image

convert thumbnail.gif \( +clone -channel a -separate +channel -negate \
\( -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 -mosaic rounded_corners_shade_1.png

Image

see
http://www.imagemagick.org/Usage/thumbnails/#rounded
http://www.imagemagick.org/script/comma ... hp?#shadow
http://www.imagemagick.org/Usage/blur/#shadow
http://www.imagemagick.org/Usage/thumbnails/#shadow
http://www.imagemagick.org/Usage/thumbn ... ded_border
Last edited by fmw42 on 2011-06-19T11:17:32-07:00, edited 1 time in total.

marciano
Posts: 10
Joined: 2011-06-18T15:09:09-07:00
Authentication code: 8675308

Re: Round corners

Post by marciano » 2011-06-19T09:52:05-07:00

Hello, thanks for your help.
Regrettably this is the 'up-to-date' version from my Centos 5.6 repo
This is web server I prefer not to make upgrades by myself.
Imagick php extension makes the script write quite simple but I also get the same out-to-date problem.

In your example I get this error msg
convert: image sequence is required `+clone'
Thank you
PS: the option alpha is still in this command

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Round corners

Post by fmw42 » 2011-06-19T11:16:51-07:00

try my modified command earlier that does not use -alpha extract. see the part in blue.

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Round corners

Post by fmw42 » 2011-06-19T16:57:38-07:00


redunbar
Posts: 1
Joined: 2019-08-15T13:48:23-07:00
Authentication code: 1152

Re: Round corners

Post by redunbar » 2019-08-15T14:00:00-07:00

I have tried the method you suggested, using the -alpha extract version. It does exactly what I needed, but seems extremely slow. I'm relatively new to Imagemagick, so I don't understand it completely yet. Is there a way to to create the mask and save it for reuse, thus saving the time it takes to create the mask each time? In my application, which is creating modified images to be applied to t-shirts, I need to run it against potentially thousands of images, and as it stands, as an octogenarian, I doubt I'll live long enough to finish the project.

Post Reply