{"record":{"id":"13a9b52f0a9d64f2","repo":"SixLabors/ImageSharp","slug":"image-cannot-be-loaded-available-decoders-formatname","errorCode":null,"errorMessage":"Image cannot be loaded. Available decoders: - {formatName} : {decoderTypeName}","messagePattern":"Image cannot be loaded\\. Available decoders: - (.+?) : (.+?)","errorType":"exception","errorClass":"UnknownImageFormatException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/Formats/ImageFormatManager.cs","lineNumber":229,"sourceCode":"    }\n\n    /// <summary>\n    /// Sets the max header size.\n    /// </summary>\n    private void SetMaxHeaderSize() => this.MaxHeaderSize = this.imageFormatDetectors.Max(x => x.HeaderSize);\n\n    [DoesNotReturn]\n    internal static void ThrowInvalidDecoder(ImageFormatManager manager)\n    {\n        StringBuilder sb = new();\n        sb = sb.AppendLine(\"Image cannot be loaded. Available decoders:\");\n\n        foreach (KeyValuePair<IImageFormat, IImageDecoder> val in manager.ImageDecoders)\n        {\n            sb = sb.AppendFormat(CultureInfo.InvariantCulture, \" - {0} : {1}{2}\", val.Key.Name, val.Value.GetType().Name, Environment.NewLine);\n        }\n\n        throw new UnknownImageFormatException(sb.ToString());\n    }\n}\n","sourceCodeStart":211,"sourceCodeEnd":232,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/Formats/ImageFormatManager.cs#L211-L232","documentation":"ImageFormatManager.ThrowInvalidDecoder builds a message listing all registered decoders and throws UnknownImageFormatException when no decoder is registered that can read the detected format. It means the format is known (or unknown) but no matching IImageDecoder is configured in the format manager.","triggerScenarios":"Calling Image.Load/Identify on data whose detected IImageFormat has no entry in Configuration.Formats' image decoders map — e.g. a stripped Configuration that removed default decoders, or a custom format registered without a decoder.","commonSituations":"Building a minimal Configuration and forgetting ImageConfiguration.Default decoders; custom IImageFormat registered via Configure but decoder not added to ImageDecoders; typos when replacing default formats; plugin assembly not loaded so the decoder type is missing.","solutions":["Use Configuration.Default (or ensure all default formats/decoders remain registered) instead of a bare new Configuration()","Register a decoder for the format: configuration.Formats.SetDecoder(MyFormat.Instance, new MyDecoder())","Ensure the assembly containing the decoder is referenced and loaded","Check the exception message's 'Available decoders' list to see what is registered and add the missing one"],"exampleFix":"// before\nvar config = new Configuration(); // no decoders registered\nvar image = Image.Load(config, stream); // UnknownImageFormatException\n// after\nvar config = new Configuration(new JpegDecoder(), new PngDecoder());\nvar image = Image.Load(config, stream);","handlingStrategy":"validation","validationCode":"var format = config.Formats.FirstOrDefault(f => Image.DetectFormat(stream)?.Name == f.Name);\nif (format is null) throw new InvalidOperationException($\"No decoder registered for detected format.\");","typeGuard":"static bool HasDecoder(Configuration cfg, IImageFormat fmt) => cfg.Formats.GetDecoder(fmt) is not null;","tryCatchPattern":"try { var image = Image.Load(config, stream); }\ncatch (UnknownImageFormatException ex)\n{\n    logger.LogError(ex, \"No decoder available for this format\");\n}","preventionTips":["Start from Configuration.Default rather than a bare Configuration","Register a decoder for every custom IImageFormat you add","Include decoder assemblies in the deployment output"],"tags":["dotnet","image-decoding","configuration","missing-decoder"],"backgroundTag":"resource-not-found","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"}