Search code examples
imagemagickimagemagick-convert

Why doesn't my Imagemagick convert consider the loop parameter?


I'm using this command:

convert -delay 10 -loop 1 -density 300 myfile.pdf myfile.gif

on Windows 10 and all works well except for the loop parameter: even if I set it to 1, I always get an infinite loop.

What am I doing wrong?


Solution

  • I did some experiments varying the -loop parameter from 0 through 3 and using a simple red frame followed by a blue frame as follows:

    for i in 0 1 2 3; do 
       echo i=$i
       ((d=80+i))
       convert -delay $d -loop $i -size 256x256 xc:red xc:blue a.gif
       identify -verbose a.gif | grep -E "Iter|Delay"
    done
    

    Results

    i=0
      Delay: 80x100
      Iterations: 0
      Delay: 80x100
      Iterations: 0
    i=1
      Delay: 81x100
      Delay: 81x100
    i=2
      Delay: 82x100
      Iterations: 2
      Delay: 82x100
      Iterations: 2
    i=3
      Delay: 83x100
      Iterations: 3
      Delay: 83x100
      Iterations: 3
    

    So, it seems that the -delay parameter and -loop parameter ARE correctly set in the GIF file, although the -loop is omitted if it is 1 which is the default anyway.

    I then looked at my animated GIF in OSX using the quicklook feature where you tap the (SPACEBAR) in Finder and it does not respect the -loop setting, however, if you open the GIF in Safari or Firefox it does respect the setting, so I am guessing it is not very standardised and whatever you are using to view the GIF files is not compliant with the poorly-followed standard.

    I may be wrong but try using a different viewer such as Firefox or Chrome.