{"record":{"id":"8825d987bf708ccc","repo":"MiniMax-AI/skills","slug":"image-format-ext-is-not-supported-by-openxml","errorCode":null,"errorMessage":"Image format '{ext}' is not supported by OpenXML.","messagePattern":"Image format '(.+?)' is not supported by OpenXML\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ImageSamples.cs","lineNumber":913,"sourceCode":"    /// <summary>\n    /// Maps file extensions to OpenXML PartTypeInfo values via ImagePartType.\n    /// In SDK 3.x, ImagePartType is a static class whose members return PartTypeInfo.\n    /// </summary>\n    private static PartTypeInfo GetImagePartType(string imagePath)\n    {\n        string ext = Path.GetExtension(imagePath).ToLowerInvariant();\n        return ext switch\n        {\n            \".png\" => ImagePartType.Png,\n            \".jpg\" or \".jpeg\" => ImagePartType.Jpeg,\n            \".gif\" => ImagePartType.Gif,\n            \".bmp\" => ImagePartType.Bmp,\n            \".tif\" or \".tiff\" => ImagePartType.Tiff,\n            \".svg\" => ImagePartType.Svg,\n            \".emf\" => ImagePartType.Emf,\n            \".wmf\" => ImagePartType.Wmf,\n            \".ico\" => ImagePartType.Icon,\n            _ => throw new NotSupportedException(\n                $\"Image format '{ext}' is not supported by OpenXML.\")\n        };\n    }\n}\n","sourceCodeStart":895,"sourceCodeEnd":918,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ImageSamples.cs#L895-L918","documentation":"`throw new NotSupportedException($\"Image format '{ext}' is not supported by OpenXML.\")` in the `GetImagePartType` switch's default arm. The helper maps a file extension to an `ImagePartType`; only png/jpg/jpeg/gif/bmp/tif/tiff/svg/emf/wmf/ico are recognized. Any other extension (e.g. `.webp`, `.heic`, `.avif`, `.raw`) falls through to the throw because OpenXML's packaging SDK has no corresponding part type.","triggerScenarios":"Calling the helper with a path whose extension is not in the supported set — most commonly `.webp`, `.heic`, `.avif`, `.tga`, or a file with no/uppercase extension that wasn't normalized (note the code lower-cases the extension, so case is not the issue).","commonSituations":"Modern formats like WebP/HEIC/AVIF that Word/OpenXML do not natively package, missing extensions, or uncommon formats like `.psd`/`.raw`.","solutions":["Convert the image to a supported format first (PNG for transparency, JPEG for photos) using an image library before passing the path.","Add a mapping case if your target actually supports the format (rare; OpenXML defines a fixed set).","Verify the path has a real extension: `Path.GetExtension(path)` returns empty for extensionless files."],"exampleFix":"// before — WebP not supported\nvar partType = GetImagePartType(\"photo.webp\"); // throws\n\n// after — convert to PNG first\nusing (var img = SixLabors.ImageSharp.Image.Load(\"photo.webp\"))\n    img.Save(\"photo.png\");\nvar partType = GetImagePartType(\"photo.png\"); // ImagePartType.Png","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> Supported =\n    new() { \".png\", \".jpg\", \".jpeg\", \".gif\", \".bmp\", \".tif\", \".tiff\", \".svg\", \".emf\", \".wmf\", \".ico\" };\n\nstring ext = Path.GetExtension(imagePath).ToLowerInvariant();\nif (!Supported.Contains(ext))\n    throw new ArgumentException($\"Convert '{ext}' to PNG/JPEG before embedding.\");","typeGuard":"bool IsSupportedImageFormat(string path)\n{\n    var ext = Path.GetExtension(path).ToLowerInvariant();\n    return ext is \".png\" or \".jpg\" or \".jpeg\" or \".gif\" or \".bmp\"\n        or \".tif\" or \".tiff\" or \".svg\" or \".emf\" or \".wmf\" or \".ico\";\n}","tryCatchPattern":"try\n{\n    var type = GetImagePartType(imagePath);\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"not supported\"))\n{\n    // convert to PNG then retry\n    var png = ConvertToPng(imagePath);\n    var type = GetImagePartType(png);\n}","preventionTips":["Restrict uploads/inputs to PNG/JPEG and convert others at ingestion time.","Validate the extension against the supported set before calling the helper.","For modern formats (WebP/HEIC/AVIF), transcode to PNG/JPEG with an image library first.","Reject extensionless files early with a clear user-facing message."],"tags":["csharp","openxml","docx","images","file-format","validation"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}