{"record":{"id":"6b339080b6564e30","repo":"SixLabors/ImageSharp","slug":"the-ani-file-contains-an-unsupported-frame-format","errorCode":null,"errorMessage":"The ANI file contains an unsupported frame format.","messagePattern":"The ANI file contains an unsupported frame format\\.","errorType":"exception","errorClass":"InvalidImageContentException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Ani/AniDecoderCore.cs","lineNumber":696,"sourceCode":"    /// </summary>\n    /// <typeparam name=\"TPixel\">The destination pixel type.</typeparam>\n    /// <param name=\"format\">The embedded resource format.</param>\n    /// <param name=\"options\">The nested decoder options.</param>\n    /// <param name=\"stream\">The bounded resource stream.</param>\n    /// <param name=\"cancellationToken\">The token to monitor for cancellation requests.</param>\n    /// <returns>The decoded resource.</returns>\n    private static Image<TPixel> DecodeFrame<TPixel>(AniFrameFormat format, DecoderOptions options, Stream stream, CancellationToken cancellationToken)\n        where TPixel : unmanaged, IPixel<TPixel>\n        => format switch\n        {\n            AniFrameFormat.Ico => new IcoDecoderCore(options).Decode<TPixel>(options.Configuration, stream, cancellationToken),\n            AniFrameFormat.Cur => new CurDecoderCore(options).Decode<TPixel>(options.Configuration, stream, cancellationToken),\n            AniFrameFormat.Bmp => new BmpDecoderCore(new BmpDecoderOptions\n            {\n                GeneralOptions = options,\n                SkipFileHeader = true\n            }).Decode<TPixel>(options.Configuration, stream, cancellationToken),\n            _ => throw new InvalidImageContentException(\"The ANI file contains an unsupported frame format.\")\n        };\n\n    /// <summary>\n    /// Identifies one embedded ANI frame resource.\n    /// </summary>\n    /// <param name=\"format\">The embedded resource format.</param>\n    /// <param name=\"options\">The nested decoder options.</param>\n    /// <param name=\"stream\">The bounded resource stream.</param>\n    /// <param name=\"cancellationToken\">The token to monitor for cancellation requests.</param>\n    /// <returns>The identified resource.</returns>\n    private static ImageInfo IdentifyFrame(AniFrameFormat format, DecoderOptions options, Stream stream, CancellationToken cancellationToken)\n        => format switch\n        {\n            AniFrameFormat.Ico => new IcoDecoderCore(options).Identify(options.Configuration, stream, cancellationToken),\n            AniFrameFormat.Cur => new CurDecoderCore(options).Identify(options.Configuration, stream, cancellationToken),\n            AniFrameFormat.Bmp => new BmpDecoderCore(new BmpDecoderOptions\n            {\n                GeneralOptions = options,","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Ani/AniDecoderCore.cs#L678-L714","documentation":"Thrown by AniDecoderCore.Decode when an embedded ANI frame's format is not one of the supported decoders (Cur, Ico via CurDecoderCore, or raw Bmp via BmpDecoderCore with SkipFileHeader). Indicates the resolved AniFrameFormat fell outside the handled switch cases.","triggerScenarios":"Decoding an ANI file whose embedded frame resource resolves to an unhandled AniFrameFormat value during Decode.","commonSituations":"ANI files with malformed icon headers that map to an unexpected format, corrupted files, or future/unknown resource types written by other encoders.","solutions":["Ensure embedded frame resources are valid ICO, CUR, or BMP data by re-exporting the ANI.","Inspect the embedded resource headers to confirm the format resolves to a supported type.","Catch InvalidImageContentException and skip or reject the offending frame."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var image = await Image.LoadAsync(stream); } catch (InvalidImageContentException ex) { SkipFrameOrReject(ex); }","preventionTips":["Re-export ANI files with compliant tools so embedded frames are ICO/CUR/BMP","Test decode of generated ANI files in CI","Catch InvalidImageContentException around decode of untrusted content"],"tags":["image-decoding","ani","unsupported-format","frames"],"backgroundTag":"unsupported-enum-value","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"}