SixLabors/ImageSharp · error · InvalidImageContentException
APNG Image does not contain a default data chunk.
Error message
APNG Image does not contain a default data chunk.
What it means
Thrown when decoding an APNG (animated PNG) that declares animation but lacks the default image data chunk (IDAT, or an fdAT with sequence number 0 acting as the default frame). The APNG spec requires a default image that all frames are composited over.
Solutions
- Re-generate the APNG ensuring a valid default image (IDAT with preceding fcTL of seq 0) is present.
- Re-encode the animation with a spec-compliant tool (e.g. ffmpeg -plays 0 output, apngasm).
- If a still image is expected, check whether the input is really an APNG and decode the intended variant.
- Catch InvalidImageContentException to fall back to alternative handling.
Example fix
// before (ffmpeg, missing default image) ffmpeg -i frames%d.png -plays 0 out.png // after ffmpeg -i frame0.png -i frames%d.png -plays 0 out.png // frame0 supplies the default IDAT
Defensive patterns
Strategy: validation
Try / catch
try
{
using var image = Image.Load(stream);
}
catch (InvalidImageContentException ex) when (ex.Message.Contains("default data chunk"))
{
// malformed APNG — fall back to an alternate source or placeholder
} Prevention
- Generate APNGs only with spec-compliant encoders (apngasm, ffmpeg with default image).
- Do not strip IDAT from APNG files when editing chunk data.
- Validate APNG structure with a dedicated checker before decoding.
When it happens
Trigger: Decoding an APNG containing acTL and fcTL/fdAT chunks but no default image data; files where the default frame's fcTL and IDAT were stripped while animation metadata remained.
Common situations: APNGs produced by tools that only emit animation frames, files edited to remove the still image but not the animation metadata, corrupted animation exports.
Related errors
- PNG Image must contain a header chunk and it must be…
- PNG Image does not contain a data chunk.
- APNG Image must contain a acTL chunk and it must be located…
- One of APNG Image's frames do not have a frame control…
- Invalid or . . Was ' ' and ' '.
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/10465d652af7f491.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/Formats/Png/PngThrowHelper.cs:21
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.Formats.Png;
internal static class PngThrowHelper
{
[DoesNotReturn]
public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);
[DoesNotReturn]
public static void ThrowInvalidHeader() => throw new InvalidImageContentException("PNG Image must contain a header chunk and it must be located before any other chunks.");
[DoesNotReturn]
public static void ThrowNoData() => throw new InvalidImageContentException("PNG Image does not contain a data chunk.");
[DoesNotReturn]
public static void ThrowMissingDefaultData() => throw new InvalidImageContentException("APNG Image does not contain a default data chunk.");
[DoesNotReturn]
public static void ThrowInvalidAnimationControl() => throw new InvalidImageContentException("APNG Image must contain a acTL chunk and it must be located before any IDAT and fdAT chunks.");
[DoesNotReturn]
public static void ThrowMissingFrameControl() => throw new InvalidImageContentException("One of APNG Image's frames do not have a frame control chunk.");
[DoesNotReturn]
public static void ThrowMissingPalette() => throw new InvalidImageContentException("PNG Image does not contain a palette chunk.");
[DoesNotReturn]
public static void ThrowInvalidChunkType() => throw new InvalidImageContentException("Invalid PNG data.");
[DoesNotReturn]
public static void ThrowInvalidChunkType(string message) => throw new InvalidImageContentException(message);
[DoesNotReturn]
public static void ThrowInvalidChunkCrc(string chunkTypeName) => throw new InvalidImageContentException($"CRC Error. PNG {chunkTypeName} chunk is corrupt!");View on GitHub (pinned to 59ce6af6fc)