Page 1 of 1

Crop Animated Gif with xc:transparent and -composite

Posted: 2013-11-08T11:11:20-07:00
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.

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

Posted: 2013-11-08T12:24:54-07:00
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

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

Posted: 2013-11-09T08:22:44-07:00
by davide.gurgone
Perfect!!!
If I use xc:transparent instead of plasma:fractal I have exactly what I whant!!! :)

Thanks a lot!

Davide.