d2phap/ImageGlass · error · FormatException
IGE: Unsupported image format.
Error message
IGE: Unsupported image format.
What it means
Thrown by MagickCodec.SaveAsync when CanWrite(destFilePath) is false. CanWrite delegates to MagickFormatInfo.Create(destFilePath)?.SupportsWriting, which resolves the encoder from the destination file extension. The check runs before any decode, so the source image is irrelevant; only the destination extension matters.
Source
Thrown at source/ImageGlass.Lib/Common/Photoing/Codecs/MagickCodecs/MagickCodec.cs:770
/// Save the photo to file.
/// </summary>
/// <param name="meta">Source metadata</param>
/// <param name="destFilePath">Destination filename</param>
/// <param name="options">Options for reading image file</param>
/// <param name="transform">Changes for writing image file</param>
/// <param name="quality">Quality</param>
/// <exception cref="Exception"></exception>
public static async Task SaveAsync(PhotoMetadata meta, string destFilePath, PhotoReadOptions options,
PhotoTransform? transform = null, uint quality = 100, CancellationToken token = default)
{
var destExt = Path.GetExtension(destFilePath);
try
{
// 1. check if format is supported
if (!CanWrite(destFilePath))
{
throw new FormatException("IGE: Unsupported image format.");
}
// 2. read the photo
var settings = ParseSettings(options, true, meta.FilePath);
using var result = await DecodeImageAsync(meta, options with
{
// Magick.NET auto-corrects the rotation when saving,
// so we don't need to correct it manually.
CorrectRotation = false,
}, settings, transform, token);
// 3. save the photo to file
if (result.MultiFrames is not null)
{
// convert GIF to non-GIF formats, we need to coalesce all frames
if (meta.FileExtension.Equals(".gif", StringComparison.OrdinalIgnoreCase)View on GitHub (pinned to 4a3c4fecef)
Solutions
- Call MagickCodec.CanWrite(destFilePath) before SaveAsync and fall back to a known-good extension such as .png or .jpg.
- Verify the destination has a recognized image extension and is spelled/cased correctly.
- If HEIC/AVIF write is required, deploy the Magick.NET native asset that includes the encoder for that runtime.
- Surface the unsupported extension to the user in the Save dialog so they can pick a supported format.
Example fix
// before
await MagickCodec.SaveAsync(meta, destFilePath, options, transform, quality, token);
// after
if (!MagickCodec.CanWrite(destFilePath))
{
destFilePath = Path.ChangeExtension(destFilePath, ".png");
}
await MagickCodec.SaveAsync(meta, destFilePath, options, transform, quality, token); Defensive patterns
Strategy: validation
Validate before calling
if (!MagickCodec.CanWrite(destFilePath))
throw new InvalidOperationException($"No encoder for '{destFilePath}'."); Try / catch
try { await MagickCodec.SaveAsync(meta, destFilePath, options, transform, quality, token); }
catch (FormatException ex) when (ex.Message.Contains("Unsupported image format"))
{ destFilePath = Path.ChangeExtension(destFilePath, ".png"); /* retry */ } Prevention
- Restrict the Save As dialog to extensions MagickCodec.CanWrite returns true for.
- Always pass a destination with a concrete, correctly-spelled extension.
- Confirm the Magick.NET native asset for the target runtime ships the encoder you need.
When it happens
Trigger: Calling SaveAsync with a destination whose extension has no Magick.NET encoder: an unknown/typo extension, an extension whose native encoder is not shipped in the loaded Magick.Native asset (e.g., HEIC/AVIF on some builds), or a path with no extension at all.
Common situations: User picks 'Save As' for a format the bundled Magick.NET build cannot write; cross-platform build differences where HEIC write is available on Windows but not Linux; saving to a file whose extension case or spelling does not map to a known MagickFormat.
Related errors
- IGE: Unsupported image format.
- The base64 content is invalid.
- IGE_002
- IGE: '{codec.CodecName}' could not write the image. {result.
- IGE: frame too large to encode.
AI-assisted analysis of d2phap/ImageGlass@4a3c4fecef (2026-08-13).
Data as JSON: /api/errors/1ace0b025f544ee0.
Report an issue: GitHub.