ACanal
ACanal

Reputation: 35

Apply rounded corners to gif with ImageMagick

I have a bunch of animated gifs that I would like to add rounded corners to. I have looked at this page:

http://www.imagemagick.org/Usage/thumbnails/#rounded

But unable to get the rounded corners to apply to an animated gif. Is it possible to do this with ImageMagick? Any help would be appreciated!

Upvotes: 1

Views: 603

Answers (1)

fmw42
fmw42

Reputation: 53089

In Imagemagick, you need to use -layers composite with a null: separator as follows:

Unix Syntax:

Input:

enter image description here

convert animation.gif -coalesce \
null: \
\( animation.gif[0]  -alpha extract \
-draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) \
-alpha off -compose CopyOpacity \
-layers composite \
-layers optimize \
animation_rounded.gif


enter image description here

See https://imagemagick.org/Usage/anim_mods/#composite

Because your output is GIF, which only supports binary transparency (off or on full), the corners will not be smoothly rounded.

Upvotes: 1

Related Questions