SixLabors/ImageSharp · error · InvalidImageContentException

The ANI file does not contain any frame resources.

Error message

The ANI file does not contain any frame resources.

What it means

During ANI decoding, after parsing the RIFF chunks the decoder collects frame resources (icon entries). If the resource list is empty the file declares no usable frames, so Decode throws InvalidImageContentException. An animation with zero frames cannot produce an image.

Solutions

  1. Verify the file is a complete ANI containing 'fram' chunks with embedded icon data (open in a cursor editor to confirm).
  2. Re-obtain or re-export the animated cursor from its original source.
  3. Catch InvalidImageContentException and fall back to a static cursor (.cur/.ico) or a placeholder image.
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the RIFF container has frame data before decoding (byte sniff):
// ANIM header 'anih' with nFrames > 0 is a weak precondition; full validation
// requires chunk parsing, so guard at decode time instead.

Try / catch

try { using var img = Image.Load(aniStream); }
catch (InvalidImageContentException ex) when (ex.Message.Contains("frame resources"))
{ UsePlaceholderCursor(); }

Prevention

When it happens

Trigger: Decoding an .ani file whose 'fram'/'icon' sub-chunks are absent or whose fram chunk contains no icon entries — e.g. a truncated file or a container that only holds metadata chunks (rate/seq) without icon data.

Common situations: Renamed non-ANI files (e.g. a .cur or RIFF file renamed to .ani); partially downloaded cursors; animated cursors stripped of their embedded icon payloads by a sanitizer or packager.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13). Data as JSON: /api/errors/00b17bd1e02ce742. Report an issue: GitHub.

Appendix: source

Thrown at src/ImageSharp/Formats/Ani/AniDecoderCore.cs:76

        bool outputFramesOwned = false;

        try
        {
            // Container parsing runs first because seq/rate chunks can occur after the frame list and affect how resources are projected.
            resources.EnsureCapacity((int)Math.Min(this.header.FrameCount, this.Options.MaxFrames));
            this.ProcessFrameChunks(stream, resources, (format, frameStream) =>
            {
                cancellationToken.ThrowIfCancellationRequested();

                Image<TPixel> resource = DecodeFrame<TPixel>(format, frameOptions, frameStream, cancellationToken);
                this.Dimensions = new Size(Math.Max(this.Dimensions.Width, resource.Width), Math.Max(this.Dimensions.Height, resource.Height));

                return resource;
            });

            if (resources.Count is 0)
            {
                throw new InvalidImageContentException("The ANI file does not contain any frame resources.");
            }

            // Keep the owners alive and resolve their spans once; sequence and rate lookup occurs for every animation step.
            IMemoryOwner<uint>? sequenceOwner = this.sequence;
            bool hasSequence = sequenceOwner is not null;
            ReadOnlySpan<uint> sequence = sequenceOwner is null ? [] : sequenceOwner.GetSpan();
            ReadOnlySpan<uint> rates = this.rates is null ? [] : this.rates.GetSpan();
            int stepCount = hasSequence ? sequence.Length : resources.Count;
            int maxFrames = (int)this.Options.MaxFrames;
            outputFrames.EnsureCapacity(Math.Min(maxFrames, resources.Count));

            for (int step = 0; step < stepCount && outputFrames.Count < maxFrames; step++)
            {
                cancellationToken.ThrowIfCancellationRequested();

                uint resourceIndex = hasSequence ? sequence[step] : (uint)step;
                if (resourceIndex >= resources.Count || resources[(int)resourceIndex] is not { } resource)
                {

View on GitHub (pinned to 59ce6af6fc)