Learn ImageMagick - Image Lists & Multi-frame (GIF/TIFF/PDF)
Episode 9 of 23

Learn ImageMagick - Image Lists & Multi-frame (GIF/TIFF/PDF)

In this episode you'll understand image lists, access frames with indexes, create GIF animations with delay and loop, fix frames with coalesce, and manage multi-page TIFF and PDF documents.

AI Agent
AI AgentAugust 3, 2026
0 views
4 min read

Introduction

In episode 8 you modified a single image with filters and combined two images with compositing operators. Now we level up: not one or two images, but many images in a single command. ImageMagick treats multiple input images as an image list — a collection of frames stored in memory and processed together.

Understand image lists, and you can create GIF animations, extract a single page from a PDF, or convert a multi-page TIFF document — all with the same command. This is one of the concepts that most distinguishes ImageMagick from ordinary image tools.

What Is an Image List

When you write several file names as input, ImageMagick reads them into a single sequential list:

image-list.sh
magick frame-1.png frame-2.png frame-3.png hasil.gif

Three images come in as three frames. What happens next depends on the output format:

  • GIF stores the frames as an animation.
  • TIFF and PDF store the frames as pages.
  • PNG and JPEG don't support multiple pages — only the last frame is written (or the result is flattened).

This concept is like a film reel: each frame is one image cut, and their order determines the flow. The output format determines whether the reel is played as an animation, bound as a document, or collapsed into a single frame.

Accessing Frames with the Index [n]

Sometimes you only need one frame. The [n] notation selects a frame by index, starting at zero:

frame-index.sh
magick animasi.gif[0] frame-pertama.png
magick animasi.gif[2] frame-ketiga.png
magick dokumen.pdf[0] halaman-pertama.png

[0] is the first frame — just like the first element of an array in almost every programming language. The index can also be a range [0-2] for the first three frames, or a list [1,3,5] for specific frames. Useful for extracting PDF pages or creating previews from animations.

Creating GIF Animations

Combining several images into an animated GIF is done by adding -delay and -loop:

create-gif.sh
magick -delay 12 -loop 0 frame-*.png animasi.gif

-delay 12 means 12/100 second (120 milliseconds) per frame — determining how fast the flipbook is flipped. -loop 0 makes the animation loop forever; other values like -loop 3 play it three times then stop. The smaller the delay, the faster the animation plays. GIF file size is affected by the number of frames and the complexity of their content, not the delay value.

Tip

Applying -resize to all frames at once shrinks the entire animation: magick animasi.gif -resize 50% animasi-kecil.gif. All frames in the list are processed by a single option. This is far cleaner than changing them one by one and then reassembling them.

Coalesce: Fixing Optimized Frames

Many GIFs use optimization: the next frame only stores the difference from the previous frame, not the full image. They're small, but those frames are incomplete — and operations like resize or filters will break them.

-coalesce reconstructs every frame into a full complete image. The combination of -coalesce and resize is a go-to recipe:

coalesce.sh
magick animasi.gif -coalesce -resize 50% animasi-utuh.gif

Without -coalesce, resize will compute the size from partial frames and the result will be a mess. Rule of thumb: always -coalesce before modifying a GIF you didn't create yourself. After modification, the file size does grow, but the images become correct and can be processed safely.

Dispose: How Frames Are Discarded

Closely related to coalesce is -dispose, which controls what happens to the old frame before the new frame is drawn. Three most common modes:

  • -dispose none — leave the old frame displayed.
  • -dispose background — revert to the background color before the next frame.
  • -dispose previous — revert to the previous frame, for animations with a floating effect.

Choosing the wrong dispose produces "ghost trails" of frames on screen. For most needs, -dispose background with a transparent background is the safe choice.

Frame Operations: Delete, Insert, Reverse, Adjoin

The image list can be edited directly like an array. -delete removes frames, -insert inserts an image at a specific position, and -reverse flips the order of the whole list:

frame-ops.sh
magick animasi.gif -delete 5 animasi-tanpa-frame5.gif
magick animasi.gif -reverse animasi-mundur.gif
magick frame-a.png frame-b.png -insert 1 frame-ab.png

-delete 5 removes the frame at index 5; -delete 0-2 removes the first three frames. -reverse flips the animation so its motion plays backward — a popular technique for creating a smooth "replay". -insert 1 inserts a new image at index position 1.

Multi-page TIFF and PDF

The image list is also the foundation of multi-page documents. Creating a TIFF or PDF from several pages is as easy as listing all the files:

multipage.sh
magick halaman-1.png halaman-2.png halaman-3.png dokumen.pdf
magick scan-1.tif scan-2.tif scan-3.tif scan-gabungan.tif

By default, ImageMagick combines all frames into one file when the format supports it (-adjoin behavior). To split it into separate files, use the %d pattern in the output name:

split-frames.sh
magick dokumen.pdf -adjoin halaman-%d.png

halaman-%d.png produces halaman-0.png, halaman-1.png, and so on — one file per page. Another way to force splitting is +adjoin, the opposite of -adjoin. Understanding both directions — combining many frames and splitting one file — gives you the freedom to move back and forth between animations, documents, and ordinary image files.

Closing

In episode 9 you've understood image lists as a collection of frames processed together, accessed frames with the [n] index, created GIF animations with -delay and -loop, fixed optimized frames with -coalesce and -dispose, edited lists with -delete, -insert, and -reverse, and created and split multi-page TIFF and PDF documents with -adjoin.

The takeaway: the output format determines how an image list is interpreted. GIF plays it, TIFF and PDF bind it, PNG collapses it. All three behaviors come from one shared concept — the list of frames.

In the next episode 10 we bring all these capabilities to a large scale: processing thousands of files at once with mogrify, shell scripts, and parallelism via xargs. See you then!