Crop Animated Gif with xc:transparent and -composite

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
davide.gurgone
Posts: 2
Joined: 2013-11-08T10:57:16-07:00
Authentication code: 6789

Crop Animated Gif with xc:transparent and -composite

Post by davide.gurgone »

Hi all,
thanks a lot for this library, it has saved me the life many times!

I have a script that puts the original image into a bigger area, filling the new empty space with a transparency:

This is the script:

Code: Select all

convert image.gif -resize 300x250 -size 300x250 xc:transparent +swap -gravity center -composite image-small.gif
To do that I have to use the -composite option, but unfortunately this let the image loose the animation. I can see the first frame only.

I tried using -coalesce, but nothing has changed.. Someone know how can I preserve the original animation?
I think I have to change the script a little bit and clone the empty background in all of the image frames, but I really don't know how to do that...

Any help is appreciate!

Thank's a lot! Davide.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Crop Animated Gif with xc:transparent and -composite

Post by fmw42 »

I am not an expert but see the example at

Code: Select all

convert -size 100x100 plasma:fractal null: \( script_k.gif -coalesce \) \
              -gravity Center   -layers Composite \
          -layers Optimize   composite_background.gif

http://www.imagemagick.org/Usage/anim_mods/#background

replace the fractal image with a transparent image of the size desired and script_k.gif with your animation file
davide.gurgone
Posts: 2
Joined: 2013-11-08T10:57:16-07:00
Authentication code: 6789

Re: Crop Animated Gif with xc:transparent and -composite

Post by davide.gurgone »

Perfect!!!
If I use xc:transparent instead of plasma:fractal I have exactly what I whant!!! :)

Thanks a lot!

Davide.
Post Reply