{"record":{"id":"1323b392520e3a32","repo":"d2phap/ImageGlass","slug":"ige-codec-codecname-could-not-write-the-image","errorCode":null,"errorMessage":"IGE: '{codec.CodecName}' could not write the image. {result.Error}","messagePattern":"IGE: '(.+?)' could not write the image\\. (.+?)","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Common/Photoing/Codecs/Registry/CodecEncodePipeline.cs","lineNumber":77,"sourceCode":"\n        var tempPath = BuildTempPath(destFilePath);\n        SweepStaleTempFiles(destFilePath);\n\n        try\n        {\n            var result = isMultiFrame\n                ? await EncodeMultiFrameAsync(codec, photo, tempPath, transform, quality, token).ConfigureAwait(false)\n                : await EncodeSingleFrameAsync(codec, photo, tempPath, transform, quality, token).ConfigureAwait(false);\n\n            if (result.Unsupported)\n            {\n                TryDelete(tempPath);\n                return false;\n            }\n            if (!result.Succeeded)\n            {\n                TryDelete(tempPath);\n                throw new InvalidDataException(\n                    $\"IGE: '{codec.CodecName}' could not write the image. {result.Error}\".TrimEnd());\n            }\n\n            if (!TryPromote(tempPath, destFilePath, out var moveError))\n            {\n                TryDelete(tempPath);\n                throw new IOException($\"IGE: could not finalize '{destFilePath}'. {moveError}\".TrimEnd());\n            }\n\n            return true;\n        }\n        catch (OperationCanceledException)\n        {\n            TryDelete(tempPath);\n            throw;\n        }\n        catch\n        {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Common/Photoing/Codecs/Registry/CodecEncodePipeline.cs#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait CodecEncodePipeline.TryEncodeAsync(photo, destFilePath, transform, quality, token);\n\n// after\ntry\n{\n    await CodecEncodePipeline.TryEncodeAsync(photo, destFilePath, transform, quality, token);\n}\ncatch (InvalidDataException ex) when (ex.Message.StartsWith(\"IGE:\"))\n{\n    // plugin encode failed; fall back to a supported extension\n    destFilePath = Path.ChangeExtension(destFilePath, \".png\");\n    await photo.SaveAsAsync(destFilePath, transform, quality, token);\n}","handlingStrategy":"try-catch","validationCode":"var codec = Core.CodecRegistry.SelectEncodeCodec(destFilePath);\nif (codec is null || codec is MagickCodecAdapter) return; // built-in path, no plugin throw","typeGuard":null,"tryCatchPattern":"try { await CodecEncodePipeline.TryEncodeAsync(photo, destFilePath, transform, quality, token); }\ncatch (InvalidDataException ex) when (ex.Message.StartsWith(\"IGE:\"))\n{ var pluginError = ex.Message; /* fall back to a supported extension or report */ }","preventionTips":["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."],"tags":["codec","plugin","encode","pipeline"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}