d2phap/ImageGlass · error · InvalidDataException

IGE: '{codec.CodecName}' could not write the image. {result.

Error message

IGE: '{codec.CodecName}' could not write the image. {result.Error}

What it means

Thrown by CodecEncodePipeline.TryEncodeAsync when a registered plugin encoder was selected for the destination extension but its EncodeAsync returned Succeeded=false. The pipeline wraps the codec name and the plugin-supplied error string in an InvalidDataException. This is distinct from result.Unsupported, which silently returns false to let the built-in Magick path take over.

Source

Thrown at source/ImageGlass.Lib/Common/Photoing/Codecs/Registry/CodecEncodePipeline.cs:77

        var tempPath = BuildTempPath(destFilePath);
        SweepStaleTempFiles(destFilePath);

        try
        {
            var result = isMultiFrame
                ? await EncodeMultiFrameAsync(codec, photo, tempPath, transform, quality, token).ConfigureAwait(false)
                : await EncodeSingleFrameAsync(codec, photo, tempPath, transform, quality, token).ConfigureAwait(false);

            if (result.Unsupported)
            {
                TryDelete(tempPath);
                return false;
            }
            if (!result.Succeeded)
            {
                TryDelete(tempPath);
                throw new InvalidDataException(
                    $"IGE: '{codec.CodecName}' could not write the image. {result.Error}".TrimEnd());
            }

            if (!TryPromote(tempPath, destFilePath, out var moveError))
            {
                TryDelete(tempPath);
                throw new IOException($"IGE: could not finalize '{destFilePath}'. {moveError}".TrimEnd());
            }

            return true;
        }
        catch (OperationCanceledException)
        {
            TryDelete(tempPath);
            throw;
        }
        catch
        {

View on GitHub (pinned to 4a3c4fecef)

Solutions

  1. Read result.Error in the exception message for the plugin-specific root cause.
  2. Update or reinstall the plugin and confirm its native dependencies load.
  3. Force the built-in Magick path by disabling the plugin or saving to an extension the plugin does not claim.
  4. Report the error string to the plugin author; include the source format, destination extension, transform, and quality.

Example fix

// before
await CodecEncodePipeline.TryEncodeAsync(photo, destFilePath, transform, quality, token);

// after
try
{
    await CodecEncodePipeline.TryEncodeAsync(photo, destFilePath, transform, quality, token);
}
catch (InvalidDataException ex) when (ex.Message.StartsWith("IGE:"))
{
    // plugin encode failed; fall back to a supported extension
    destFilePath = Path.ChangeExtension(destFilePath, ".png");
    await photo.SaveAsAsync(destFilePath, transform, quality, token);
}
Defensive patterns

Strategy: try-catch

Validate before calling

var codec = Core.CodecRegistry.SelectEncodeCodec(destFilePath);
if (codec is null || codec is MagickCodecAdapter) return; // built-in path, no plugin throw

Try / catch

try { await CodecEncodePipeline.TryEncodeAsync(photo, destFilePath, transform, quality, token); }
catch (InvalidDataException ex) when (ex.Message.StartsWith("IGE:"))
{ var pluginError = ex.Message; /* fall back to a supported extension or report */ }

Prevention

When it happens

Trigger: A plugin codec whose SelectEncodeCodec claimed the destination extension, but the actual encode failed: out-of-memory in the plugin, an unsupported sub-format or color space, a transform the plugin cannot apply, or a bug in the plugin's encoder.

Common situations: Third-party plugin that over-claims supported extensions; plugin partially uninstalled or missing a native dependency; plugin removed between codec selection and the encode call; plugin does not handle the requested quality/transform combination.

Related errors


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