SixLabors/ImageSharp · error · UnknownImageFormatException
No encoder was found for extension
Error message
No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include: What it means
A format was successfully detected from the file extension, but the Configuration's ImageFormatsManager has no IImageEncoder registered for that specific IImageFormat. The format is known but cannot be encoded, so UnknownImageFormatException is thrown listing each registered format/encoder pair.
Solutions
- Register an encoder for the format: configuration.ImageFormatsManager.SetEncoder(format, new MyFormatEncoder())
- Check the error message's list to confirm which format/encoder pairs are registered
- Save with an explicitly supplied encoder instead of format detection: image.Save(path, encoder)
Example fix
// before
configuration.Configure(new MyFormat()); // format registered, encoder missing
image.Save("file.myext");
// after
configuration.Configure(new MyFormat());
configuration.ImageFormatsManager.SetEncoder(MyFormat.Instance, new MyFormatEncoder());
image.Save("file.myext"); Defensive patterns
Strategy: validation
Validate before calling
var format = configuration.ImageFormatsManager.FindEncoderByExtension?;
// pre-check: every registered format must have an encoder
foreach (var fmt in configuration.ImageFormats)
if (configuration.ImageFormatsManager.GetEncoder(fmt) is null)
throw new InvalidOperationException($"No encoder registered for {fmt.Name}"); Try / catch
try { image.Save(path); }
catch (UnknownImageFormatException ex) { logger.LogError(ex, "Encoder missing for detected format at {Path}", path); } Prevention
- After Configure/registration, assert each format has an encoder via ImageFormatsManager.GetEncoder
- Register encoder explicitly: ImageFormatsManager.SetEncoder(format, encoder)
- Use explicit encoder parameters when the configuration is not fully under your control
When it happens
Trigger: Calling image.Save(path) where the extension maps to a detected IImageFormat (e.g. a custom format or a format registered in ImageFormats but not in ImageEncoders), and ImageFormatsManager.GetEncoder(format) returns null.
Common situations: Registering a custom IImageFormat via configuration.Configure(...) but forgetting to also register its encoder with ImageFormatsManager.SetEncoder(format, encoder); a configuration where a format was added without its encoder; mismatched format/encoder registration after copying configuration settings.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- No encoder was found for extension
- maxDegreeOfParallelism
- ANI bitmap resources require a supported bit depth.
- ANI bitmap resources require exactly one color plane.
- Image cannot be loaded. Available decoders
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/c974e35f90c65d1a.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/Advanced/AdvancedImageExtensions.cs:53
{
sb = sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", fmt.Name, string.Join(", ", fmt.FileExtensions), Environment.NewLine);
}
throw new UnknownImageFormatException(sb.ToString());
}
IImageEncoder? encoder = source.Configuration.ImageFormatsManager.GetEncoder(format);
if (encoder is null)
{
StringBuilder sb = new();
sb = sb.AppendLine(CultureInfo.InvariantCulture, $"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
foreach (KeyValuePair<IImageFormat, IImageEncoder> enc in source.Configuration.ImageFormatsManager.ImageEncoders)
{
sb = sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", enc.Key, enc.Value.GetType().Name, Environment.NewLine);
}
throw new UnknownImageFormatException(sb.ToString());
}
return encoder;
}
/// <summary>
/// Accepts a <see cref="IImageVisitor"/> to implement a double-dispatch pattern in order to
/// apply pixel-specific operations on non-generic <see cref="Image"/> instances
/// </summary>
/// <param name="source">The source image.</param>
/// <param name="visitor">The image visitor.</param>
public static void AcceptVisitor(this Image source, IImageVisitor visitor)
=> source.Accept(visitor);
/// <summary>
/// Accepts a <see cref="IImageVisitor"/> to implement a double-dispatch pattern in order to
/// apply pixel-specific operations on non-generic <see cref="Image"/> instances
/// </summary>View on GitHub (pinned to 59ce6af6fc)