Page 1 of 2
Fill background in animated gif?
Posted: 2013-10-05T18:26:58-07:00
by Smoshy
I have a sequence of .pngs, which comprise a blue background with an actor somewhere in the middle. I want to make this into a compact .gif, showing just the actor. I'm using this command line :
Code: Select all
convert r:\in.*.png -set delay 1x24 -coalesce -trim -set dispose background -layers TrimBounds r:\out.gif
Which is almost perfect, but for one problem. Each frame of the gif that is smaller than the gif itself, is filled with a black background. How can I fill that with a plain background colour of my choice?
I bring pictures.
How do I deal with the black blocks? They vex me so.
Re: Fill background in animated gif?
Posted: 2013-10-05T18:42:45-07:00
by fmw42
perhaps you need to trim twice (with -fuzz XX%), once for the white and once for the black. and do a -layers optimize
Re: Fill background in animated gif?
Posted: 2013-10-05T18:45:23-07:00
by Smoshy
fmw42 wrote:perhaps you need to trim twice (with -fuzz XX%), once for the white and once for the black. and do a -layers optimize
YES!
I SHALL NAME MY FIRSTBORN fmw42!
Re: Fill background in animated gif?
Posted: 2013-10-05T18:51:10-07:00
by Smoshy
fmw42 wrote:perhaps you need to trim twice (with -fuzz XX%), once for the white and once for the black. and do a -layers optimize
Wait, no.
First, the white is an artifact of the screengrab, I'm not worried about that.
I followed your advice, and it works if I use '-background blue' or '-background red'. Any other colour leaves horrible black trails as the animation changes size. Still, it's a lead.
Re: Fill background in animated gif?
Posted: 2013-10-05T18:52:42-07:00
by fmw42
that may (or may not) be an issue with your IM version. what version and platform are you using?
do your images have transparency?
Re: Fill background in animated gif?
Posted: 2013-10-05T18:57:15-07:00
by Smoshy
fmw42 wrote:that may (or may not) be an issue with your IM version. what version and platform are you using?
Windows 7 x64
Code: Select all
Version: ImageMagick 6.8.6-10 2013-09-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib freetype jbig jng jp2 jpeg lcms png ps png tiff webp xml zlib
fmw42 wrote:do your images have transparency?
No, they're all opaque .pngs.
Here's what I mean; I used '-background khaki'.
Re: Fill background in animated gif?
Posted: 2013-10-05T21:35:23-07:00
by fmw42
Include -fuzz XX% and keep increasing the percent until it cleans all the black. Your black is likely not pure black.
Re: Fill background in animated gif?
Posted: 2013-10-06T04:56:25-07:00
by Smoshy
Any black is being put there by convert - my source frames have a blue background.
Adding fuzz
Code: Select all
convert r:\in.*.png -set delay 1x24 -coalesce -fuzz 50% -trim -set dispose background -colors 256 +dither -layers TrimBounds -background khaki -layers optimize r:\out.gif
gives
How can I take a pile of images with one background colour and convert them into an animation with the same background colour?
Re: Fill background in animated gif?
Posted: 2013-10-06T10:56:17-07:00
by fmw42
this works just fine for me on one image in IM 6.8.7.0 Q16 Mac OSX
convert LgZBweF.png -fuzz 50% -trim -colors 256 +dither -layers trimbounds -background khaki -layers optimize test.gif
Re: Fill background in animated gif?
Posted: 2013-10-06T11:09:42-07:00
by Smoshy
Not for me...
Can I upload attachments here? A small zip of a few source frames might be helpful...
Re: Fill background in animated gif?
Posted: 2013-10-06T12:47:11-07:00
by fmw42
You will need to upload to some free image hosting service such as dropbox and then put links to them here. There is no direct image upload in this forum
Re: Fill background in animated gif?
Posted: 2013-10-06T13:03:20-07:00
by Smoshy
http://www.4shared.com/zip/GR-Kpf-y/frames.html
The first 24 frames. Thanks for your help on this.
Re: Fill background in animated gif?
Posted: 2013-10-06T14:40:52-07:00
by fmw42
Unfortunately I cannot download from there. It wants a password for logging in and I do not want to sign up just for this.
Re: Fill background in animated gif?
Posted: 2013-10-06T14:59:02-07:00
by Smoshy
Sorry, I didn't check to see if there would be any restrictions. I
have checked this, and it should be fine :
http://wikisend.com/download/686428/frames.zip
Re: Fill background in animated gif?
Posted: 2013-10-06T21:38:50-07:00
by fmw42
I am not an expert on animation disposal, but I am not sure you can change the background for -dispose background. I think you need to add a frame at the beginning with -dispose none -delay 0 and then process your images with -dispose previous. The problem with that approach is that you use -trim and that will trim the whole first image away.
see the examples on -dispose previous at
http://www.imagemagick.org/Usage/anim_basics/#previous
I gave it my best try but was unsuccessful working around this.
Perhaps some one else who is better at animations can provide further insight or wait and see what Anthony suggests.