d2phap/ImageGlass · error · FormatException

IGE: Unsupported image format.

Error message

IGE: Unsupported image format.

What it means

Thrown by SkiaCodec.SaveAsync when the destination extension is not writable by Magick.NET. SkiaCodec has no native encoder of its own; it delegates writing to MagickCodec.CanWrite, and if that returns false it throws FormatException. Same root cause as the MagickCodec.SaveAsync error, but on the Skia save entry point.

Source

Thrown at source/ImageGlass.Lib/Common/Photoing/Codecs/SkiaCodecs/SkiaCodec.cs:401

            // 1. apply transforms
            using var transformedImg = TransformImage(srcImg, transform);
            var dstImg = transformedImg ?? srcImg;
            if (dstImg.IsDisposed() || token.IsCancellationRequested) return;


            // 2. use Magick to save
            if (MagickCodec.CanWrite(destFilePath))
            {
                using var imgM = ToMagick(dstImg);
                if (imgM is null) return;

                // write image data to file
                imgM.Quality = quality;
                await imgM.WriteAsync(destFilePath, token);
            }
            else
            {
                throw new FormatException("IGE: Unsupported image format.");
            }

        }
        catch (OperationCanceledException) { }
    }


    /// <summary>
    /// Checks if the photo can be pinged to get metadata.
    /// </summary>
    public static bool CanPing(string srcFilePath)
    {
        using var codec = SKCodec.Create(srcFilePath);
        if (codec.IsDisposed()) return false;

        return true;
    }

View on GitHub (pinned to 4a3c4fecef)

Solutions

  1. Call MagickCodec.CanWrite(destFilePath) before SkiaCodec.SaveAsync and remap to a supported extension.
  2. Restrict the Save As dialog to extensions known to be writable (.png, .jpg, .tif, .bmp, .gif, .webp).
  3. Ship the Magick.NET native asset that includes the required encoder for the runtime.
  4. If a plugin owns the extension, route through CodecEncodePipeline instead of SkiaCodec.SaveAsync directly.

Example fix

// before
await SkiaCodec.SaveAsync(srcImg, destFilePath, transform, quality, token);

// after
if (!MagickCodec.CanWrite(destFilePath))
{
    destFilePath = Path.ChangeExtension(destFilePath, ".png");
}
await SkiaCodec.SaveAsync(srcImg, destFilePath, transform, quality, token);
Defensive patterns

Strategy: validation

Validate before calling

if (!MagickCodec.CanWrite(destFilePath))
    destFilePath = Path.ChangeExtension(destFilePath, ".png");

Try / catch

try { await SkiaCodec.SaveAsync(srcImg, destFilePath, transform, quality, token); }
catch (FormatException ex) when (ex.Message.Contains("Unsupported image format"))
{ destFilePath = Path.ChangeExtension(destFilePath, ".png"); /* retry */ }

Prevention

When it happens

Trigger: Calling SkiaCodec.SaveAsync with a destination extension Magick.NET cannot write: unknown extension, extension without an encoder in the loaded native asset, or a missing extension.

Common situations: Saving a Skia-decoded image (the fast path) to a format only a plugin or a fuller Magick build can write; HEIC/AVIF save on a build without the encoder; typo in the destination extension.

Related errors


AI-assisted analysis of d2phap/ImageGlass@4a3c4fecef (2026-08-13). Data as JSON: /api/errors/b0cc198e8abcdb01. Report an issue: GitHub.