{"record":{"id":"3cf2f29ffc523165","repo":"d2phap/ImageGlass","slug":"ige-001","errorCode":"IGE_001","errorMessage":"IGE_001: Unsupported image format.","messagePattern":"IGE_001: Unsupported image format\\.","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"v9/Components/ImageGlass.Base/Photoing/Codecs/PhotoCodec.cs","lineNumber":455,"sourceCode":"\n    /// <summary>\n    /// Save as image file, use Magick.NET.\n    /// </summary>\n    /// <param name=\"srcFileName\">Source filename to save</param>\n    /// <param name=\"destFilePath\">Destination filename</param>\n    /// <param name=\"readOptions\">Options for reading image file</param>\n    /// <param name=\"transform\">Changes for writing image file</param>\n    /// <param name=\"quality\">Quality</param>\n    /// <exception cref=\"FileFormatException\"></exception>\n    public static async Task SaveAsync(string srcFileName, string destFilePath, CodecReadOptions readOptions, ImgTransform? transform = null, uint quality = 100, CancellationToken token = default)\n    {\n        var ext = Path.GetExtension(destFilePath).ToUpperInvariant();\n\n        try\n        {\n            if (!CheckSupportFormatForSaving(destFilePath))\n            {\n                throw new FileFormatException(\"IGE_001: Unsupported image format.\");\n            }\n\n            var settings = ParseSettings(readOptions, true, srcFileName);\n\n\n            using var imgData = await ReadMagickImageAsync(\n                srcFileName,\n                Path.GetExtension(srcFileName),\n                settings,\n                readOptions with\n                {\n                    // Magick.NET auto-corrects the rotation when saving,\n                    // so we don't need to correct it manually.\n                    CorrectRotation = false,\n                }, transform, token);\n\n            if (imgData.MultiFrameImage != null)\n            {","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/v9/Components/ImageGlass.Base/Photoing/Codecs/PhotoCodec.cs#L437-L473","documentation":"Thrown by PhotoCodec.SaveAsync (v9) when CheckSupportFormatForSaving(destFilePath) returns false. That helper delegates to MagickFormatInfo.Create(destFilePath).SupportsWriting, i.e. Magick.NET decides from the destination file extension whether it can encode that format. If the extension is unknown, unregistered, or a read-only/decompress-only format for Magick.NET, SaveAsync throws FileFormatException. The error code IGE_001 is ImageGlass's internal identifier for 'cannot write this image format'.","triggerScenarios":"Saving to a destination whose extension Magick.NET cannot write — e.g. '.heic', '.avif' (without the right Magick build), '.cr2', '.tiff' variants not enabled, or a typo'd/unknown extension; calling SaveAsync after changing the Save-As extension to something Magick.NET's SupportsWriting reports false for.","commonSituations":"User picks an obscure or raw-camera format in Save As; the Magick.NET package in use lacks the codec delegates for that format; a custom extension mapping points to a non-writable MagickFormat; building ImageGlass without the full Magick.NET native deps.","solutions":["Verify the destination extension is in Magick.NET's writable set before calling (see validationCode) and restrict the Save-As picker to those extensions.","Install/enable the Magick.NET delegate (e.g. HEIC/AVIF/AOM) appropriate for the format, or switch to a Magick.NET build that includes it.","Fall back to a known-good writable format (PNG/JPEG) when the requested one is unsupported.","Catch FileFormatException at the call site and show the user which extension was rejected."],"exampleFix":"// before\nawait PhotoCodec.SaveAsync(src, destPath, readOpts);\n\n// after: gate on SupportsWriting\nvar info = MagickFormatInfo.Create(destPath);\nif (info is null || !info.SupportsWriting)\n    throw new InvalidOperationException($\"Cannot save to '{destPath}': format not writable by Magick.NET.\");\nawait PhotoCodec.SaveAsync(src, destPath, readOpts);","handlingStrategy":"validation","validationCode":"// Confirm Magick.NET can write the destination extension before saving.\nvar fmt = MagickFormatInfo.Create(destFilePath);\nif (fmt is null || !fmt.SupportsWriting)\n    throw new InvalidOperationException($\"Format not writable: {Path.GetExtension(destFilePath)}\");","typeGuard":null,"tryCatchPattern":"try { await PhotoCodec.SaveAsync(src, destPath, readOpts); }\ncatch (FileFormatException ex) when (ex.Message.Contains(\"IGE_001\"))\n{ /* destination format not writable by Magick.NET */ }","preventionTips":["Restrict the Save-As picker to extensions where MagickFormatInfo.SupportsWriting is true.","Install the Magick.NET build/delegates for formats like HEIC/AVIF if you need them.","Validate the extension before queuing a save in batch flows."],"tags":["magick-net","image-format","save","codec","fileformatexception","imageglass","v9"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}