Page 1 of 1

Combining multiple animated gifs into a single longer animation - Using too much disk space

Posted: 2019-08-18T18:54:46-07:00
by LockStock
Hi, I'm trying to combine 277 short gif files into a single long gif animation. Each gif is approximately 9 MB in size and has 30 frames.

I'm using this command to do this.

Code: Select all

magick *.gif out.gif
Unfortunately the process fails as I run out of disk space (which seems strange to me as I have 80 GB of free space on my drive). Here's the error message it throws once I run out of space.

Code: Select all

magick: unable to write pixel cache '/var/folders/7f/w4ftkq_j4p140_hpzq2t3y1c0000gn/T/magick-7165--NoElTFXUtB': No space left on device @ error/cache.c/WritePixelCachePixels/5624.
magick: corrupt image `temp161.gif' @ error/gif.c/DecodeImage/505.
magick: corrupt image `temp161.gif' @ error/gif.c/ReadGIFImage/1365.
I think the corrupt image error is only because it's unable to read in that image correctly as it runs out of space once it get's up to it (gif 161 of 277). Why does it take so much disk space to combine these gifs? Is there a better way todo this?

Running:
OSX 10.14.5 with 16 GB of RAM.
ImageMagick 7.0.7-24 Q16 x86_64 2018-02-26

Edit:
Also tried with
ImageMagick 7.0.8-59 Q16 x86_64 2019-08-05

Re: Combining multiple animated gifs into a single longer animation - Using too much disk space

Posted: 2019-08-18T21:17:12-07:00
by fmw42
Edit you policy.xml file to permit more RAM or map to disk. See

https://imagemagick.org/script/resources.php
https://imagemagick.org/source/policy.xml

You can use

Code: Select all

magick -list resource 
to see what your allocation is.

When using wild cards for input, be sure your files are listed alphabetically the way you want them to be put in the output.

Note that you need RAM to hold all the input files and the output also allowing for conversion to full 32-bit frames in the Q level of your compile.

Re: Combining multiple animated gifs into a single longer animation - Using too much disk space

Posted: 2019-08-18T21:53:30-07:00
by LockStock
Thanks @fmw42

I just checked my allocation and it is currently set to this:

Code: Select all

Resource limits:
  Width: 107.374MP
  Height: 107.374MP
  Area: 34.3597GP
  List length: unlimited
  Memory: 16GiB
  Map: 32GiB
  Disk: unlimited
  File: 192
  Thread: 8
  Throttle: 0
  Time: unlimited
So magick is permitted to use unlimited disk space and all 16 GB of my RAM. Is it normal to use > 80 GB of disk space to combine just 2.5 GB of gif files?

Also files are properly named to get the desired output.

Cheers

Re: Combining multiple animated gifs into a single longer animation - Using too much disk space

Posted: 2019-08-18T22:10:24-07:00
by fmw42
What are the dimensions of the gif frames in width and height. Have you computed 277 images * 30 frames/image * Width * Height * 4 bytes/pixel and double it for input and output? Is that result larger or smaller than your RAM.

Sorry I am not an expert on resource allocations and mapping to disk.

Re: Combining multiple animated gifs into a single longer animation - Using too much disk space

Posted: 2019-08-18T22:34:18-07:00
by LockStock
All good. The gifs are 1280 x 960 pixels. So using your formula I'm looking at about 81 GB. I'm going to clear another 100 GB of space and see if it runs to completion after that.

Re: Combining multiple animated gifs into a single longer animation - Using too much disk space

Posted: 2019-08-19T01:20:50-07:00
by LockStock
Hey @fmw42,

I managed to get this working. It required about 230 GB of disk space in the end. Interestingly could only get it working using:

Code: Select all

convert *.gif out.gif
I could not get it working using the magick command. As a possible future feature suggestion, do you think it would be possible to render a gif like this by continuously appending the desired gifs together without having to load every file into the memory? I'm not familiar with how this stuff works under the hood.

Thanks for your help.

Re: Combining multiple animated gifs into a single longer animation - Using too much disk space

Posted: 2019-08-19T05:40:15-07:00
by magick
See https://imagemagick.org/script/architec ... tera-pixel. Try this command:

Code: Select all

convert -monitor -limit memory 2GiB -limit map 4GiB -define registry:temporary-path=./ *.gif out.gif