MiniMax-AI/skills · error · NotSupportedException

Image format '{ext}' is not supported by OpenXML.

Error message

Image format '{ext}' is not supported by OpenXML.

What it means

`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.

Source

Thrown at skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ImageSamples.cs:913

    /// <summary>
    /// Maps file extensions to OpenXML PartTypeInfo values via ImagePartType.
    /// In SDK 3.x, ImagePartType is a static class whose members return PartTypeInfo.
    /// </summary>
    private static PartTypeInfo GetImagePartType(string imagePath)
    {
        string ext = Path.GetExtension(imagePath).ToLowerInvariant();
        return ext switch
        {
            ".png" => ImagePartType.Png,
            ".jpg" or ".jpeg" => ImagePartType.Jpeg,
            ".gif" => ImagePartType.Gif,
            ".bmp" => ImagePartType.Bmp,
            ".tif" or ".tiff" => ImagePartType.Tiff,
            ".svg" => ImagePartType.Svg,
            ".emf" => ImagePartType.Emf,
            ".wmf" => ImagePartType.Wmf,
            ".ico" => ImagePartType.Icon,
            _ => throw new NotSupportedException(
                $"Image format '{ext}' is not supported by OpenXML.")
        };
    }
}

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. Convert the image to a supported format first (PNG for transparency, JPEG for photos) using an image library before passing the path.
  2. Add a mapping case if your target actually supports the format (rare; OpenXML defines a fixed set).
  3. Verify the path has a real extension: `Path.GetExtension(path)` returns empty for extensionless files.

Example fix

// before — WebP not supported
var partType = GetImagePartType("photo.webp"); // throws

// after — convert to PNG first
using (var img = SixLabors.ImageSharp.Image.Load("photo.webp"))
    img.Save("photo.png");
var partType = GetImagePartType("photo.png"); // ImagePartType.Png
Defensive patterns

Strategy: validation

Validate before calling

static readonly HashSet<string> Supported =
    new() { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tif", ".tiff", ".svg", ".emf", ".wmf", ".ico" };

string ext = Path.GetExtension(imagePath).ToLowerInvariant();
if (!Supported.Contains(ext))
    throw new ArgumentException($"Convert '{ext}' to PNG/JPEG before embedding.");

Type guard

bool IsSupportedImageFormat(string path)
{
    var ext = Path.GetExtension(path).ToLowerInvariant();
    return ext is ".png" or ".jpg" or ".jpeg" or ".gif" or ".bmp"
        or ".tif" or ".tiff" or ".svg" or ".emf" or ".wmf" or ".ico";
}

Try / catch

try
{
    var type = GetImagePartType(imagePath);
}
catch (NotSupportedException ex) when (ex.Message.Contains("not supported"))
{
    // convert to PNG then retry
    var png = ConvertToPng(imagePath);
    var type = GetImagePartType(png);
}

Prevention

When it happens

Trigger: 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).

Common situations: Modern formats like WebP/HEIC/AVIF that Word/OpenXML do not natively package, missing extensions, or uncommon formats like `.psd`/`.raw`.

Related errors


AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13). Data as JSON: /api/errors/8825d987bf708ccc. Report an issue: GitHub.