SixLabors/ImageSharp · error · NotSupportedException

Unsupported EXR version

Error message

Unsupported EXR version

What it means

Thrown when an EXR file's version field is unsupported. The EXR header version number encodes format version and flags (single-part, tiled, multi-part, deep); this decoder only supports certain versions/layouts. Files with unknown or unsupported version flags cannot be read.

Solutions

  1. Re-export the EXR as a single-part scanline file with a supported version (oiiotool input.exr -o output.exr)
  2. Upgrade ImageSharp to a version with broader EXR version support
  3. Verify the file is a complete, valid EXR (exrheader) rather than truncated/corrupt

Example fix

// before
var image = Image.Load(exrStream);
// after
using var fs = File.OpenRead(path);
byte[] head = new byte[8]; fs.Read(head, 0, 8);
if (head[4] > 2 || (head[5] & 0x10) != 0) // version > 2 or deep-data flag
    ConvertToScanlineExr(path);
var image = Image.Load(path);
Defensive patterns

Strategy: try-catch

Validate before calling

// Check EXR version byte before decode
using var fs = File.OpenRead(path);
var header = new byte[8];
if (fs.Read(header, 0, 8) < 8) throw new InvalidDataException("Not EXR");
if (header[4] > 2 || (header[5] & 0x10) != 0) throw new NotSupportedException("Deep/multipart EXR not supported");

Try / catch

try { return Image.Load(stream); }
catch (NotSupportedException ex) when (ex.Message == "Unsupported EXR version") { return ConvertToScanlineExr(stream); }

Prevention

When it happens

Trigger: Image.Load/Decode on an EXR whose version byte is not a supported version (e.g. deep data or a future format version, or a corrupted header byte).

Common situations: Reading EXR files produced by very new OpenEXR writers using deep/tiled multi-part extensions, or reading truncated files where the version byte is garbage.

Related errors


AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13). Data as JSON: /api/errors/87d02b155261a0b1. Report an issue: GitHub.

Appendix: source

Thrown at src/ImageSharp/Formats/Exr/ExrThrowHelper.cs:20

// Licensed under the Six Labors Split License.

using System.Diagnostics.CodeAnalysis;

namespace SixLabors.ImageSharp.Formats.Exr;

/// <summary>
/// Cold path optimizations for throwing exr format based exceptions.
/// </summary>
internal static class ExrThrowHelper
{
    [DoesNotReturn]
    public static Exception NotSupportedDecompressor(string compressionType) => throw new NotSupportedException($"Not supported decoder compression method: {compressionType}");

    [DoesNotReturn]
    public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage);

    [DoesNotReturn]
    public static void ThrowNotSupportedVersion() => throw new NotSupportedException("Unsupported EXR version");

    [DoesNotReturn]
    public static void ThrowNotSupported(string msg) => throw new NotSupportedException(msg);

    [DoesNotReturn]
    public static void ThrowInvalidImageHeader() => throw new InvalidImageContentException("Invalid EXR image header");

    [DoesNotReturn]
    public static void ThrowInvalidImageHeader(string msg) => throw new InvalidImageContentException(msg);

    [DoesNotReturn]
    public static Exception NotSupportedCompressor(string compressionType) => throw new NotSupportedException($"Not supported encoder compression method: {compressionType}");
}

View on GitHub (pinned to 59ce6af6fc)