SixLabors/ImageSharp · error · InvalidImageContentException
The ANI file does not contain any identifiable animation…
Error message
The ANI file does not contain any identifiable animation steps.
What it means
After projecting all animation steps during identification, the decoder requires at least one identifiable step to build the returned ImageInfo. If every step was skipped (invalid sequence references, undecodable resources) the identification has no meaningful frame metadata and throws InvalidImageContentException. This is the identification-path counterpart of the decode-time 'no decodable animation steps' error.
Solutions
- Validate the ANI file integrity (RIFF size vs actual size) before identification; re-obtain the file if truncated.
- Re-export the cursor/animation ensuring 'fram'/'icon' chunks contain valid image data.
- Catch InvalidImageContentException around Identify and treat the file as unidentifiable rather than ANI.
Example fix
// before
IImageInfo info = await Image.IdentifyAsync(stream);
// after
try { IImageInfo info = await Image.IdentifyAsync(stream); }
catch (InvalidImageContentException ex) { Log(ex); return null; } Defensive patterns
Strategy: try-catch
Validate before calling
// Require both RIFF/ACON signature and a minimum size before identification bool candidate = new FileInfo(path).Length >= 64;
Try / catch
try
{
IImageInfo info = await Image.IdentifyAsync(stream);
}
catch (InvalidImageContentException)
{
return null; // no identifiable animation steps
} Prevention
- Check file integrity (size vs RIFF declared size) before identification.
- Avoid feeding stripped or partially rebuilt ANI files into Identify.
- Cache known-good ANI files and verify hashes after download.
When it happens
Trigger: Calling Image.IdentifyAsync on an ANI stream where zero steps survive: fully-invalid 'seq ' chunk, all resources failed to parse, or steps array empty.
Common situations: Badly truncated ANI downloads; container files whose icon payloads were stripped; misidentified non-ANI streams reaching the ANI decoder.
Related errors
- The ANI file does not contain any decodable animation steps.
- The ANI sequence references a missing frame resource.
- The ANI RIFF container size is invalid.
- Invalid window size for ZLIB header: cinfo=
- Bad method for ZLIB header: cmf=
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/b7f28804ed80536a.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/Formats/Ani/AniDecoderCore.cs:224
// Some embedded decoders expose only resource-level dimensions, so synthesize the one required ANI frame entry.
ImageFrameMetadata target = new();
target.SetFormatMetadata(AniFormat.Instance, CreateFrameMetadata(null, format, step + 1, frameDelay, info.Size));
outputFrames.Add(target);
continue;
}
for (int i = 0; i < info.FrameMetadataCollection.Count && outputFrames.Count < maxFrames; i++)
{
ImageFrameMetadata source = info.FrameMetadataCollection[i];
ImageFrameMetadata target = new();
target.SetFormatMetadata(AniFormat.Instance, CreateFrameMetadata(source, format, step + 1, frameDelay, info.Size));
outputFrames.Add(target);
}
}
if (outputFrames.Count is 0)
{
throw new InvalidImageContentException("The ANI file does not contain any identifiable animation steps.");
}
return new ImageInfo(this.Dimensions, this.imageMetadata, outputFrames);
}
/// <summary>
/// Parses the RIFF container and records frame-list boundaries for subsequent embedded decoding.
/// </summary>
/// <param name="stream">The ANI stream.</param>
private void ParseContainer(BufferedReadStream stream)
{
// Parser-owned chunk state is replaced by the container currently being scanned.
this.frameLists.Clear();
this.sequence?.Dispose();
this.rates?.Dispose();
this.sequence = null;
this.rates = null;
View on GitHub (pinned to 59ce6af6fc)