{"record":{"id":"a76414fd013481a8","repo":"SixLabors/ImageSharp","slug":"gif-image-does-not-contain-a-logical-screen-descriptor","errorCode":null,"errorMessage":"Gif image does not contain a Logical Screen Descriptor.","messagePattern":"Gif image does not contain a Logical Screen Descriptor\\.","errorType":"exception","errorClass":"InvalidImageContentException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Gif/GifThrowHelper.cs","lineNumber":15,"sourceCode":"// Copyright (c) Six Labors.\n// Licensed under the Six Labors Split License.\n\nusing System.Diagnostics.CodeAnalysis;\n\nnamespace SixLabors.ImageSharp.Formats.Gif;\n\ninternal static class GifThrowHelper\n{\n    [DoesNotReturn]\n    public static void ThrowInvalidImageContentException(string errorMessage)\n        => throw new InvalidImageContentException(errorMessage);\n\n    [DoesNotReturn]\n    public static void ThrowNoHeader() => throw new InvalidImageContentException(\"Gif image does not contain a Logical Screen Descriptor.\");\n\n    [DoesNotReturn]\n    public static void ThrowNoData() => throw new InvalidImageContentException(\"Unable to read Gif image data\");\n}\n","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Gif/GifThrowHelper.cs#L1-L20","documentation":"Thrown when the GIF decoder cannot read the Logical Screen Descriptor immediately after the header signature. A valid GIF must contain 'GIF8xa' followed by a 7-byte screen descriptor; absence means the file is too short or not a GIF. Raised as InvalidImageContentException.","triggerScenarios":"Image.Load/Decode where after reading the GIF signature the stream cannot supply the full LogicalScreenDescriptor bytes (stream ended or bytes invalid).","commonSituations":"Files with a GIF magic number but truncated bodies (bad uploads), zero-byte or few-byte files, or streams consumed partially by earlier code before being passed to the decoder.","solutions":["Ensure the stream is rewound to position 0 and not partially consumed before passing to Image.Load","Validate the file is at least ~13 bytes (header + LSD) before decoding","Re-upload/re-export the image; the file is truncated","Check content-type handling so non-GIF payloads are not routed to the GIF decoder"],"exampleFix":"// before\nvar image = Image.Load(stream);\n// after\nif (stream.CanSeek) stream.Position = 0;\nif (stream.Length < 13) throw new InvalidDataException(\"Too small to be a GIF\");\nvar image = Image.Load(stream);","handlingStrategy":"validation","validationCode":"// Confirm GIF header + Logical Screen Descriptor are present\nif (stream.CanSeek)\n{\n    var head = new byte[13];\n    long pos = stream.Position; int n = stream.Read(head, 0, 13); stream.Position = pos;\n    if (n < 13 || !System.Text.Encoding.ASCII.GetString(head, 0, 6).StartsWith(\"GIF\")) throw new InvalidDataException(\"Not a complete GIF header\");\n}\n","typeGuard":null,"tryCatchPattern":"try { return Image.Load(stream); }\ncatch (InvalidImageContentException ex) when (ex.Message.Contains(\"Logical Screen Descriptor\")) { return RejectAsset(\"truncated-gif\", ex); }","preventionTips":["Rewind streams to position 0 before handing them to Image.Load","Require a minimum file size (~13 bytes) before decode attempts","Verify uploads finished (content-length match) before processing","Use Image.Identify to preflight formats"],"tags":["gif","decoder","header","corrupt"],"backgroundTag":"unexpected-response-shape","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"}