The upstream libvips examples build a vertical strip and then set metadata by
hand. In ol.vips, prefer
v/assemble-pages when you already have
a sequence of equal-sized frames. It joins the frames into one strip and sets
the page metadata for you.
(require '[ol.vips :as v]
'[ol.vips.operations :as ops])
(with-open [base (v/from-file "test/fixtures/puppies.jpg")
frame-a (ops/extract-area base 0 0 40 30)
frame-b (ops/extract-area base 10 10 40 30)
frame-c (ops/extract-area base 20 20 40 30)
animated (v/assemble-pages [frame-a frame-b frame-c]
{:loop 2
:delay [80 120 160]})]
(v/write-to-file animated "puppies.gif")
(select-keys (v/metadata animated)
[:width :height :pages :page-height :loop :delay]))
Here, frame-a, frame-b, and frame-c are just ordinary image handles.
v/assemble-pages does not require a special frame type. The frames
argument is simply a non-empty collection of same-sized images, with each image
becoming one animation frame in the output.
In practice, those images can come from any image-producing operation, not only
from ops/extract-area. You
can resize, crop, composite, render text, or load separate files first, then
pass the resulting image handles to v/assemble-pages.