Using dispose method to reuse background
-
- Posts: 5
- Joined: 2018-06-26T04:45:52-07:00
- Authentication code: 1152
Using dispose method to reuse background
Hello, I'm new to imagemagick, I was looking at ways to optimise a gif with a static background. I wondered if the first frame can be reused to save filesize - I thought perhaps using the dispose method.
Here's what I mean, I have a brick wall on the first frame, then a spinning ball on the following frames. I want the ball to spin on the brick wall background. Here is a version I created from a PNG sequence using dispose method 3 (keeping the previous image):
Here is the same gif generated using dispose method 1 (removing previous image)
I need the previous ball frames to dispose, keeping frame one. Is there a way to do this?
Many thanks
Here's what I mean, I have a brick wall on the first frame, then a spinning ball on the following frames. I want the ball to spin on the brick wall background. Here is a version I created from a PNG sequence using dispose method 3 (keeping the previous image):
Here is the same gif generated using dispose method 1 (removing previous image)
I need the previous ball frames to dispose, keeping frame one. Is there a way to do this?
Many thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Using dispose method to reuse background
I don't understand what is in your PNG sequence, and I'm not sure what you want for the output. I guess you want the output to be a ball in various positions against a wall. And perhaps your PNG sequence is a wall with no ball, and balls in various positions with no wall but a transparent background.
If so, then the obvious method is to compose each of the ball images over the wall, in turn:
Perhaps there is a better way with "-dispose".
If so, then the obvious method is to compose each of the ball images over the wall, in turn:
Code: Select all
magick wall.png NULL: balls*.png -compose over -layers composite -layers optimize out.gif
snibgo's IM pages: im.snibgo.com
-
- Posts: 5
- Joined: 2018-06-26T04:45:52-07:00
- Authentication code: 1152
Re: Using dispose method to reuse background
Thanks for your reply snibgo, hopefully this post will make it clearer.
The background is this, test_bg.png:
The testpngs directory is a transparent png sequence containing these images:
I almost got it working using this:
This produced an amazingly small file size of 30k, but there is a pause on the first frame. This problem is referenced in the Docs here http://www.imagemagick.org/Usage/anim_basics/#cleared:
I have tried various Optimisation methods, but nothing comes close to the file size of 30k.
If this is impossible to get rid of the jolt, then I was thinking OptimizeTransparency sounded promising, but I worry I'm over complicating it.
Any further ideas appreciated. I'm using ImageMagick 7.0.8-3 on a Mac via Terminal
Thanks again
The background is this, test_bg.png:
The testpngs directory is a transparent png sequence containing these images:
I almost got it working using this:
Code: Select all
convert -dispose none -delay 0 test_bg.png -dispose previous -delay 4 testpngs/*.png -loop 0 test.gif
I have tried various Optimisation methods, but nothing comes close to the file size of 30k.
If this is impossible to get rid of the jolt, then I was thinking OptimizeTransparency sounded promising, but I worry I'm over complicating it.
Any further ideas appreciated. I'm using ImageMagick 7.0.8-3 on a Mac via Terminal
Thanks again
snibgo wrote: ↑2018-06-26T08:34:23-07:00 I don't understand what is in your PNG sequence, and I'm not sure what you want for the output. I guess you want the output to be a ball in various positions against a wall. And perhaps your PNG sequence is a wall with no ball, and balls in various positions with no wall but a transparent background.
If so, then the obvious method is to compose each of the ball images over the wall, in turn:
Perhaps there is a better way with "-dispose".Code: Select all
magick wall.png NULL: balls*.png -compose over -layers composite -layers optimize out.gif
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Using dispose method to reuse background
Please provide the two actual input images - the brick and the circling yellow dot gif.
-
- Posts: 5
- Joined: 2018-06-26T04:45:52-07:00
- Authentication code: 1152
Re: Using dispose method to reuse background
bg image: https://imageshack.com/a/img922/926/d6c6V9.png
ball frames: https://imageshack.com/a/2Kko/1
Sorry the 49 images are separate, I couldn't find a reliable zip share site
It resizes to 160px width on output;
ball frames: https://imageshack.com/a/2Kko/1
Sorry the 49 images are separate, I couldn't find a reliable zip share site
It resizes to 160px width on output;
Code: Select all
convert -dispose none -delay 0 test_bg.png -dispose previous -delay 4 testpngs/*.png -scale 160 -loop 0 test.gif
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Using dispose method to reuse background
Make your set of yellow dot images into an animated gif and see if that has the jolt. Make that work first. If it does not have a jolt, then upload the animated gif for the yellow balls or zip all the pngs and upload that. I do not want to try downloading all your separate yellow ball pngs.
-
- Posts: 5
- Joined: 2018-06-26T04:45:52-07:00
- Authentication code: 1152
Re: Using dispose method to reuse background
Sure:
and bg again for reference:
and bg again for reference:
fmw42 wrote: ↑2018-06-26T10:52:55-07:00 Make your set of yellow dot images into an animated gif and see if that has the jolt. Make that work first. If it does not have a jolt, then upload the animated gif for the yellow balls or zip all the pngs and upload that. I do not want to try downloading all your separate yellow ball pngs.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Using dispose method to reuse background
This command works fine for me in ImageMagick 6.9.10.2 Q16 Mac OSX.
Code: Select all
convert bricks.png null: \( yellow_dots.gif -coalesce \) -layers composite -layers optimize anim.gif
-
- Posts: 5
- Joined: 2018-06-26T04:45:52-07:00
- Authentication code: 1152
Re: Using dispose method to reuse background
That works perfectly, thanks to both fmw42 & snibgo for your help
fmw42 wrote: ↑2018-06-26T15:43:11-07:00 This command works fine for me in ImageMagick 6.9.10.2 Q16 Mac OSX.
Code: Select all
convert bricks.png null: \( yellow_dots.gif -coalesce \) -layers composite -layers optimize anim.gif