{"record":{"id":"1ace0b025f544ee0","repo":"d2phap/ImageGlass","slug":"ige-unsupported-image-format","errorCode":null,"errorMessage":"IGE: Unsupported image format.","messagePattern":"IGE: Unsupported image format\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Common/Photoing/Codecs/MagickCodecs/MagickCodec.cs","lineNumber":770,"sourceCode":"    /// Save the photo to file.\n    /// </summary>\n    /// <param name=\"meta\">Source metadata</param>\n    /// <param name=\"destFilePath\">Destination filename</param>\n    /// <param name=\"options\">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=\"Exception\"></exception>\n    public static async Task SaveAsync(PhotoMetadata meta, string destFilePath, PhotoReadOptions options,\n        PhotoTransform? transform = null, uint quality = 100, CancellationToken token = default)\n    {\n        var destExt = Path.GetExtension(destFilePath);\n\n        try\n        {\n            // 1. check if format is supported\n            if (!CanWrite(destFilePath))\n            {\n                throw new FormatException(\"IGE: Unsupported image format.\");\n            }\n\n\n            // 2. read the photo\n            var settings = ParseSettings(options, true, meta.FilePath);\n            using var result = await DecodeImageAsync(meta, options 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            }, settings, transform, token);\n\n\n            // 3. save the photo to file\n            if (result.MultiFrames is not null)\n            {\n                // convert GIF to non-GIF formats, we need to coalesce all frames\n                if (meta.FileExtension.Equals(\".gif\", StringComparison.OrdinalIgnoreCase)","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Common/Photoing/Codecs/MagickCodecs/MagickCodec.cs#L752-L788","documentation":"Thrown by MagickCodec.SaveAsync when CanWrite(destFilePath) is false. CanWrite delegates to MagickFormatInfo.Create(destFilePath)?.SupportsWriting, which resolves the encoder from the destination file extension. The check runs before any decode, so the source image is irrelevant; only the destination extension matters.","triggerScenarios":"Calling SaveAsync with a destination whose extension has no Magick.NET encoder: an unknown/typo extension, an extension whose native encoder is not shipped in the loaded Magick.Native asset (e.g., HEIC/AVIF on some builds), or a path with no extension at all.","commonSituations":"User picks 'Save As' for a format the bundled Magick.NET build cannot write; cross-platform build differences where HEIC write is available on Windows but not Linux; saving to a file whose extension case or spelling does not map to a known MagickFormat.","solutions":["Call MagickCodec.CanWrite(destFilePath) before SaveAsync and fall back to a known-good extension such as .png or .jpg.","Verify the destination has a recognized image extension and is spelled/cased correctly.","If HEIC/AVIF write is required, deploy the Magick.NET native asset that includes the encoder for that runtime.","Surface the unsupported extension to the user in the Save dialog so they can pick a supported format."],"exampleFix":"// before\nawait MagickCodec.SaveAsync(meta, destFilePath, options, transform, quality, token);\n\n// after\nif (!MagickCodec.CanWrite(destFilePath))\n{\n    destFilePath = Path.ChangeExtension(destFilePath, \".png\");\n}\nawait MagickCodec.SaveAsync(meta, destFilePath, options, transform, quality, token);","handlingStrategy":"validation","validationCode":"if (!MagickCodec.CanWrite(destFilePath))\n    throw new InvalidOperationException($\"No encoder for '{destFilePath}'.\");","typeGuard":null,"tryCatchPattern":"try { await MagickCodec.SaveAsync(meta, destFilePath, options, transform, quality, token); }\ncatch (FormatException ex) when (ex.Message.Contains(\"Unsupported image format\"))\n{ destFilePath = Path.ChangeExtension(destFilePath, \".png\"); /* retry */ }","preventionTips":["Restrict the Save As dialog to extensions MagickCodec.CanWrite returns true for.","Always pass a destination with a concrete, correctly-spelled extension.","Confirm the Magick.NET native asset for the target runtime ships the encoder you need."],"tags":["codec","magick","save","format","encode"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}