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
- Read result.Error in the exception message for the plugin-specific root cause.
- Update or reinstall the plugin and confirm its native dependencies load.
- Force the built-in Magick path by disabling the plugin or saving to an extension the plugin does not claim.
- 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
- Read result.Error from the exception message before assuming a host bug.
- Keep plugins updated and confirm their native dependencies load at startup.
- If a plugin over-claims extensions, disable it or save to an extension it does not claim.
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
- IGE: Unsupported image format.
- IGE: could not finalize '{destFilePath}'. {moveError}
- IGE: Unsupported image format.
- Native codec '{CodecId}' does not support static-raster deco
- IGE: Native codec '{CodecId}' was unloaded.
AI-assisted analysis of d2phap/ImageGlass@4a3c4fecef (2026-08-13).
Data as JSON: /api/errors/1323b392520e3a32.
Report an issue: GitHub.