Masking an animated gif

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
User avatar
hellocatfood
Posts: 44
Joined: 2010-01-01T13:29:41-07:00
Authentication code: 8675309

Masking an animated gif

Post by hellocatfood »

I have an animated gif and I want to mask each frame of it then output an animated gif. I know I could separate the gif into individual frames, mask each frame and then put it back together, but just wondered if there's an easier way

Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Masking an animated gif

Post by anthony »

In what way?

Just do a rectangular crop of the animation?
http://www.imagemagick.org/Usage/anim_m ... p_viewport


Or do you want to mask each frame using another image.
You can use the multi-image layers composition for this.
http://www.imagemagick.org/Usage/anim_mods/#composite

However unless you are willing to share an example animation and mask, we can not help you further.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
hellocatfood
Posts: 44
Joined: 2010-01-01T13:29:41-07:00
Authentication code: 8675309

Re: Masking an animated gif

Post by hellocatfood »

So, I have this animated gif http://ubuntuone.com/p/RuN/ and I want to mask it using this image http://ubuntuone.com/p/RuK/ so that it looks a little like this, only animated. Is there a way to do this without having to separate the animated gif into individual frames?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Masking an animated gif

Post by anthony »

Your original animation has no timing delays!

however this does the job

Code: Select all

convert drink.gif -coalesce null: mask.jpg \
            -compose CopyOpacity -layers composite \
            drink_masked.gif
the "null:" image is important to mark the end of one sequence of images and the second compose image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
hellocatfood
Posts: 44
Joined: 2010-01-01T13:29:41-07:00
Authentication code: 8675309

Re: Masking an animated gif

Post by hellocatfood »

It worked, thanks so much! :-)
Post Reply