Search code examples
linuximageterminalimagemagickgif

Error at creating GIF Image with ImageMagick: too many exceptions and blinking problem


I have a directory with a lot of png files with the next structure:

image1.png
image2.png
...
image3372.png

I am trying to create a GIF image with ImageMagick, so in a Terminal I am typing:

sudo apt-get install imagemagick
convert -delay 0.01 -loop 0 *.png myimage.gif

But I have the next errors:

...
convert-im6.q16: DistributedPixelCache '127.0.0.1' @ error/distribute-cache.c
/ConnectPixelCacheServer/244.
convert-im6.q16: cache resources exhausted `Image119.png' @ error/cache.c/OpenPixelCache/3984.
convert-im6.q16: too many exceptions (exception processing suspended).

And the GIF created is not complete: enter image description here

Also, it blinks. I think it is because it is considering image18 and image180 as consecutive. How do I fix that?

I am running Ubuntu 18

Edit: New Image generated by xenoid suggestions enter image description here


Solution

    1. 100 frames/second is overkill. You can run with 10 frames/sec and divide the image count by 10 (or at least the standard 25 frames/sec and divide by 4).
    2. *.png is expanded and sorted alphabetically by your shell,so if you want frames in their number sequence, pad the names with 0's:
    for n in {1..3372} ; ; do mv image$n.png image$(printf "%04d" $n).png ; done
    
    1. convert (and other IM commands) uses a memory cache and has several self-enforced limits (that you can list with IM's identify command):
    >>> identify -list resource
    Resource limits:
      Width: 16KP
      Height: 16KP
      List length: 18.446744EP
      Area: 128MP
      Memory: 256MiB
      Map: 512MiB
      Disk: 1GiB
      File: 768
      Thread: 8
      Throttle: 0
      Time: unlimited
    
    • You can boost the limit for one run:
    convert -limit memory 1000  ...
    
    • For more permanent changes you can also edit /etc/ImageMagick-6/policy.xml and look for lines such as <policy domain="resource" name="memory" value="256MiB"/> and increase the necessary ones.