decodeAnimation
Decode data as an animation. GIF, APNG, animated WebP, AVIF image sequences and animated JPEG XL return every composited frame with delays and the loop count; static formats return a single zero-delay frame, so this is safe to call on anything decode accepts.
maxFrames stops the decode after that many frames, and nothing past them is read, so a damaged later frame does not fail it. 1 gives the first frame of the animation as it plays, for a thumbnail or a paused image: for an APNG whose default image sits outside the animation that is not what decode returns. The result keeps the file's delays and loop count, so it plays as only those frames would.
cancellationCheck, when given, runs between frames of a multi-frame decode and may throw to abandon work whose result no longer matters (pass { coroutineContext.ensureActive() } from a coroutine). A still in a format that cannot animate, and an AVIF or HEIC still, run it as decode does.
applyOrientation honours the EXIF orientation tag on every frame, the same way decode does for a still.
Throws
if maxFrames is less than 1