{"record":{"id":"00b17bd1e02ce742","repo":"SixLabors/ImageSharp","slug":"the-ani-file-does-not-contain-any-frame-resources","errorCode":null,"errorMessage":"The ANI file does not contain any frame resources.","messagePattern":"The ANI file does not contain any frame resources\\.","errorType":"exception","errorClass":"InvalidImageContentException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Ani/AniDecoderCore.cs","lineNumber":76,"sourceCode":"        bool outputFramesOwned = false;\n\n        try\n        {\n            // Container parsing runs first because seq/rate chunks can occur after the frame list and affect how resources are projected.\n            resources.EnsureCapacity((int)Math.Min(this.header.FrameCount, this.Options.MaxFrames));\n            this.ProcessFrameChunks(stream, resources, (format, frameStream) =>\n            {\n                cancellationToken.ThrowIfCancellationRequested();\n\n                Image<TPixel> resource = DecodeFrame<TPixel>(format, frameOptions, frameStream, cancellationToken);\n                this.Dimensions = new Size(Math.Max(this.Dimensions.Width, resource.Width), Math.Max(this.Dimensions.Height, resource.Height));\n\n                return resource;\n            });\n\n            if (resources.Count is 0)\n            {\n                throw new InvalidImageContentException(\"The ANI file does not contain any frame resources.\");\n            }\n\n            // Keep the owners alive and resolve their spans once; sequence and rate lookup occurs for every animation step.\n            IMemoryOwner<uint>? sequenceOwner = this.sequence;\n            bool hasSequence = sequenceOwner is not null;\n            ReadOnlySpan<uint> sequence = sequenceOwner is null ? [] : sequenceOwner.GetSpan();\n            ReadOnlySpan<uint> rates = this.rates is null ? [] : this.rates.GetSpan();\n            int stepCount = hasSequence ? sequence.Length : resources.Count;\n            int maxFrames = (int)this.Options.MaxFrames;\n            outputFrames.EnsureCapacity(Math.Min(maxFrames, resources.Count));\n\n            for (int step = 0; step < stepCount && outputFrames.Count < maxFrames; step++)\n            {\n                cancellationToken.ThrowIfCancellationRequested();\n\n                uint resourceIndex = hasSequence ? sequence[step] : (uint)step;\n                if (resourceIndex >= resources.Count || resources[(int)resourceIndex] is not { } resource)\n                {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Ani/AniDecoderCore.cs#L58-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the file is a complete ANI containing 'fram' chunks with embedded icon data (open in a cursor editor to confirm).","Re-obtain or re-export the animated cursor from its original source.","Catch InvalidImageContentException and fall back to a static cursor (.cur/.ico) or a placeholder image."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the RIFF container has frame data before decoding (byte sniff):\n// ANIM header 'anih' with nFrames > 0 is a weak precondition; full validation\n// requires chunk parsing, so guard at decode time instead.","typeGuard":null,"tryCatchPattern":"try { using var img = Image.Load(aniStream); }\ncatch (InvalidImageContentException ex) when (ex.Message.Contains(\"frame resources\"))\n{ UsePlaceholderCursor(); }","preventionTips":["Ensure animated cursors keep their embedded icon payloads (some sanitizers strip them).","Validate downloads (size/CRC) before decoding .ani files.","Provide a static .ico fallback for broken animated cursors."],"tags":["ani","decoder","empty-content","riff"],"backgroundTag":"empty-result-set","analyzedSha":"59ce6af6fc29027cda277ef62d4d1694a8acce91","analyzedAt":"2026-09-13T18:34:59.331Z","contentChangedAt":"2026-09-13T18:34:59.331Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}