[Resolved]dispose background for animation

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
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

[Resolved]dispose background for animation

Post by fmw42 »

IM 6.7.7.6 Q16 Mac OSX Snow Leopard

What I am trying to do is crop an image into pieces that are not always the same size and make an animation. When the cropped image is smaller than the crop dimensions, I was trying to have the frame background be some other color rather than black when using -dispose background. Is there some simple command that controls the background color for filling the frame when creating an animation? I tried adding -fill and -bacgkround but the background is still black.

Input:
Image

convert lena.jpg -crop 120x120 miff:- | convert -fill white -background white -dispose background -delay 50 - -loop 0 lena_ani.gif

Result:
Image
Last edited by fmw42 on 2012-06-06T20:24:44-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: dispose background for animation

Post by anthony »

Originally I believe GIF disposal 'background' meant to dispose of the last frame area to the background color which is stored in the GIF image.

However The web browsers never did this (starting with the first real browser 'mosaic'), but instead always disposed to 'transparency', or the page background coloror texture. As this gave GIF animations a practical and popular application, no animation program I know of actually maked proper use the 'background color' attribute of the GIF image file format, as it was intended.

In essence dispose background may as well now mean dispose to transparency, rather that dispose to background.
The background attribute is now generally ignored, though can effect some image processing options in IM (as IM will use it if the 'background' color setting has not been set when a GIF image is read in, and used).

For example

Code: Select all

  convert image.gif  -alpha remove  show:
will show the background color form the GIF image.

For example, I did not set my GIF background color properly when I saved my 'IM examples splash logo', so it can some out horible...

Code: Select all

convert http://www.imagemagick.org/Usage/images/splash.gif   -alpha remove   splash_alpha_remove.gif
Image

This is different to using the actual 'transparency color' used to define palette boolean transparency in the GIF, which you get if you just turn transparency off!

Code: Select all

convert http://www.imagemagick.org/Usage/images/splash.gif   -alpha off   splash_alpha_off.gif
Image


Note that using 'dispose previous' also means the same thing if ALL the previous frames are also all dispose previous. The only time dispose previous actually means 'previous' (rather than transparency), is if you have a previous frame that has some other form of disposal. And that dispose undefined (which is a valid disposal setting), is generally thought of as the same as dispose 'none'

Disposals are all exampled in IM Examples, Animation Basics.
http://www.imagemagick.org/Usage/anim_basics/#dispose

How animations use disposals will determine the 'style' or 'type' of animation generated.
http://www.imagemagick.org/Usage/anim_basics/#types

Mixed disposals (other than perhaps the first frame) is rare.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: dispose background for animation

Post by fmw42 »

So are you saying there is no way to put some other color there for the background?

Also if you look carefully at my animation, you see that when one frame is disposed (frames 5 and 6 starting from 1) there is a remnant slightly redish-black left behind rather than pure black. I do not get that!

P.S. See my bugs post at viewtopic.php?f=3&t=21171, which is then most likely not a bug, but a limitation of the browsers showing a proper background.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: dispose background for animation

Post by fmw42 »

Seems to be an issue with Safari. The above animation on Safari has nearly black background. On Firefox, it is transparent.

But thanks for the information about the disposal method. At least that is consistent with what I saw using Firefox and your disposal background discussion on your Examples page.
Post Reply