{"record":{"id":"f6d263b32876a087","repo":"SixLabors/ImageSharp","slug":"the-icon-file-does-not-contain-any-identifiable-image","errorCode":null,"errorMessage":"The icon file does not contain any identifiable image entries.","messagePattern":"The icon file does not contain any identifiable image entries\\.","errorType":"exception","errorClass":"InvalidImageContentException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/Icon/IconDecoderCore.cs","lineNumber":242,"sourceCode":"\n                    if (frameCount is 0)\n                    {\n                        bmpMetadata = currentBmpMetadata;\n                    }\n                }\n\n                IconFrameCompression compression = isPng ? IconFrameCompression.Png : IconFrameCompression.Bmp;\n                this.SetFrameMetadata(metadata, frameMetadata, frameCount, entry, compression, bitsPerPixel, colorTable);\n                frames[frameCount++] = frameMetadata;\n\n                // Identification uses the same embedded-header dimensions as decoding, without allocating pixel buffers.\n                this.Dimensions = new Size(Math.Max(this.Dimensions.Width, frameInfo.Width), Math.Max(this.Dimensions.Height, frameInfo.Height));\n            });\n        }\n\n        if (frameCount is 0)\n        {\n            throw new InvalidImageContentException(\"The icon file does not contain any identifiable image entries.\");\n        }\n\n        if (frameCount != frames.Length)\n        {\n            // Preserve successfully identified frames when truncated image data ends the scan before the declared directory count.\n            Array.Resize(ref frames, frameCount);\n        }\n\n        // Copy the format specific metadata to the image.\n        if (bmpMetadata is not null)\n        {\n            metadata.SetFormatMetadata(BmpFormat.Instance, bmpMetadata);\n        }\n\n        if (pngMetadata is not null)\n        {\n            metadata.SetFormatMetadata(PngFormat.Instance, pngMetadata);\n        }","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/Icon/IconDecoderCore.cs#L224-L260","documentation":"Thrown during icon identification when the directory declares entries but zero frames could be identified from the stream (frameCount is 0), possibly after truncated payload data ended the scan. SixLabors.ImageSharp throws InvalidImageContentException because there is no image information to report for Identify.","triggerScenarios":"Calling Image.Identify on an ICO/CUR whose directory entries cannot be identified — corrupt or truncated embedded payloads, or unsupported inner image data; a truncated stream may end before any child payload is parsed.","commonSituations":"Metadata probing of icon files damaged in transfer; icon files with declared directory entries whose data offsets point at garbage; security/AV tools scanning many potentially corrupt files.","solutions":["Re-download or restore the icon file and retry","Validate the file: extract each entry at ImageOffset/BytesInRes and check it is a valid PNG/BMP header","Catch InvalidImageContentException in Identify logic and treat the file as non-image or corrupt","If truncation is the cause, check the stream length against ImageOffset + BytesInRes of the last entry"],"exampleFix":"// before\nvar info = Image.Identify(\"icon.ico\");\n// after\ntry\n{\n    var info = Image.Identify(\"icon.ico\");\n}\ncatch (InvalidImageContentException)\n{\n    // icon file has no identifiable frames\n    info = null;\n}","handlingStrategy":"try-catch","validationCode":"// file must at least contain header + one 16-byte entry\nstatic bool PlausibleIcoLength(string path)\n{\n    var b = File.ReadAllBytes(path);\n    ushort count = (ushort)(b[4] | (b[5] << 8));\n    return b.Length >= 6 + 16 * count;\n}","typeGuard":"static bool IsInvalidImageContent(Exception ex) => ex is InvalidImageContentException;","tryCatchPattern":"try\n{\n    var info = Image.Identify(path);\n}\ncatch (InvalidImageContentException)\n{\n    info = null; // no identifiable frames\n}","preventionTips":["Check stream length against declared directory size before identifying","Re-transfer corrupted files rather than retrying","Log and quarantine files that repeatedly fail identification"],"tags":["icon","ico","identify","invalid-image-content"],"backgroundTag":"invalid-image-content","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"}