Preview an Image Sequence with ImageMagick animate
You will finish with a repeatable way to view one image, a numbered set of images, or an existing animated file in an X display. You will also be able to slow the sequence down, limit its size, and distinguish an image problem from a missing display.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes for a first test. You need ImageMagick 6, readable image files, and access to an X server. This guide uses the installed imagemagick-6.q16 package, version 8:6.9.12.98+dfsg1-5.2ubuntu0.1~esm13, whose executable reports ImageMagick 6.9.12-98 Q16. The command is normally unprivileged. Do not use sudo to open somebody else's display or to work around a bad file path.
1. Check the installed command and display
Confirm which executable will run and whether the shell has an X display selected:
$ command -v animate-im6.q16
/usr/bin/animate-im6.q16
$ animate-im6.q16 -version
Version: ImageMagick 6.9.12-98 Q16 x86_64 18038 https://legacy.imagemagick.org
$ printf 'DISPLAY=%s\n' "$DISPLAY"
DISPLAY=:0
The exact version line can differ after a package update. The useful checks are that the executable exists and that DISPLAY names a reachable X server. The installed manpage calls the program animate-im6.q16; the local animate and animate-im6 manpages describe the same command. Use the fully qualified name in scripts so an ImageMagick 7 installation or a different wrapper does not silently change the behaviour.
Checkpoint
If DISPLAY is empty, stop here and connect to the intended graphical session first. A remote shell may need X forwarding, and a scheduled job may have no display at all. Do not copy another user's DISPLAY value or authentication files without understanding the access implications.
2. Check the input without opening it
Use identify, a separate ImageMagick command, to check names, formats and dimensions before asking animate to open a window:
$ identify /path/to/frame-01.png /path/to/frame-02.png
/path/to/frame-01.png PNG 640x480 640x480+0+0 8-bit sRGB 2c 163B 0.000u 0:00.000
/path/to/frame-02.png PNG 640x480 640x480+0+0 8-bit sRGB 2c 163B 0.000u 0:00.000
Your metadata will differ. Check that each path is readable, the format is recognised, and the dimensions are what you expect. This is a useful separation of concerns: identify can prove that the files are image files, while animate needs an X server to display them.
If the files are numbered frames, let the shell expand them in the order you intend:
$ printf '%s\n' /path/to/frames/frame-*.png
/path/to/frames/frame-01.png
/path/to/frames/frame-02.png
/path/to/frames/frame-03.png
Do not assume that a wildcard sorts numerically. Names such as frame-1.png and frame-10.png can put frame 10 before frame 2. Rename or explicitly list files when order matters. Keep the original frames: animate displays them and does not need to rewrite them.
3. Open one image or an existing animation
Start with one known-good image. The command stays attached to the display until you close its window or interrupt it:
$ animate-im6.q16 /path/to/preview.png
For an animated GIF, pass the GIF as one input. Its image sequence and saved animation settings are read as input:
$ animate-im6.q16 /path/to/example.gif
To animate separate frames, pass all of them in order:
$ animate-im6.q16 /path/to/frames/frame-01.png /path/to/frames/frame-02.png /path/to/frames/frame-03.png
When a window appears, click it to expose the ImageMagick command widget. The installed manual documents button 1 as the control that maps or unmaps that widget. If the command immediately reports that it cannot open the X server, return to step 1. If it opens but fails on one frame, run identify on each input and test the frames individually.
4. Set a useful playback speed
The -delay image setting is measured in centiseconds. For a tenth of a second per frame, use 10:
$ animate-im6.q16 -delay 10 /path/to/frames/frame-*.png
A larger value is slower. For example, -delay 50 requests half a second. This is a request applied while the sequence is read, not a change to the source files. If a GIF already carries frame delays, an explicit command-line setting is a useful test when the stored timing is too quick to inspect.
The -loop setting controls how many times the images loop before the command exits. Combine it with a deliberately short test sequence when you need a bounded run:
$ animate-im6.q16 -delay 25 -loop 2 /path/to/frames/frame-01.png /path/to/frames/frame-02.png
Do not use an unbounded display command in an unattended job and expect it to finish. A graphical animation is an interactive viewer, not a video encoder or a service. Press the terminal interrupt key, normally Ctrl-C, if you need to stop the foreground process. Closing the window is also a normal way to end an interactive preview.
5. Fit large images to the window
Use -resize when the source images are too large for the display. The geometry 1200x800> means reduce images that exceed either bound while preserving their aspect ratio:
$ animate-im6.q16 -resize '1200x800>' /path/to/frames/frame-*.png
The quotes protect the geometry from shell metacharacter handling. The greater-than sign is part of ImageMagick's geometry syntax, so it is written as > in this article's HTML but appears as > when copied from the code block. This operation affects the displayed image sequence, not the files on disk.
If you need a fixed window position or preferred size, -geometry sets the Image window geometry. It is separate from -resize: the former concerns the X window, while the latter changes the image presented to it.
6. Diagnose the common failures
Unable to open X server: check DISPLAY, the session you are logged into, and whether your connection has X authorisation. This is not an image-format error. On a headless machine, use identify or another non-graphical workflow instead of trying random display values.
Unable to open image: inspect the exact path and permissions:
$ ls -l /path/to/preview.png
$ test -r /path/to/preview.png && echo readable
readable
The order looks wrong: print the shell-expanded arguments, then use zero-padded names or an explicit list. The sequence is too fast: add a larger -delay. One frame is corrupt: find it with identify and remove it from the preview list, rather than modifying the source archive.
Do not treat -authenticate or -decipher as ordinary viewing options for untrusted files. They involve protected image data and a password or cipher file. Keep secrets out of shell history and process listings, and only use those options when you have verified the input and the key material.
Done means
animate-im6.q16 -versionreports the expected ImageMagick 6 installation.DISPLAYpoints to an X server you are authorised to use.identifyconfirms that the intended inputs are readable images.- The frames are passed in a deliberate order, with zero-padded names where needed.
-delay,-loopand-resizeare used only for the current preview.- No source image, persistent configuration or service was changed.