Page 1 of 1

How to crop gif images into circle

Posted: 2018-03-05T00:29:30-07:00
by bkstorm
I have a gif image like this:
Image

I want to crop it into a circle.
Here is the command which I use to crop images, it works fine with static images (png, jpeg, ...), but it doesn't work with animations (gif images).

Code: Select all

convert bird.png -alpha on \( +clone -channel a -evaluate multiply 0 +channel -fill white -draw 'circle 128,128 0,128' \) -compose DstIn -composite bird-circle.png
How can I do that? Thanks.
Here is information about ImageMagick:
Version: ImageMagick 6.7.8-9 2017-09-20 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

Re: How to crop gif images into circle

Posted: 2018-03-05T01:06:16-07:00
by snibgo
Your code nearly works with Gif. The trick is to use "-layers composite", and a NULL: image. See http://www.imagemagick.org/script/comma ... php#layers

I've converted to Windows BAT syntax. You'll need to convert it back to bash.

Code: Select all

convert ^
  giphy3.gif ^
  -layers coalesce ^
  -alpha on ^
  NULL: ^
  ( -clone 0 ^
    -channel a -evaluate multiply 0 +channel -fill white ^
    -draw "circle 128,128 0,128" ^
    -repage +122+122 ) ^
  -compose DstIn -layers composite ^
  bird-circle.gif
The "-repage" centralises the circle. Adjust to taste.

Re: How to crop gif images into circle

Posted: 2018-03-05T02:46:30-07:00
by bkstorm
Thank snibgo, it works :D