SixLabors/ImageSharp · error · InvalidIccProfileException

Entry is null.

Error message

Entry is null.

What it means

Thrown by IccConverterBase.InitD when the D2B/B2D tag's data entry cannot be cast to IccMultiProcessElementsTagDataEntry (GetTag<T> returned null), meaning the tag is absent or holds a different entry type. InitD only supports multi-process elements, so a missing entry aborts profile initialization.

Solutions

  1. Ensure the profile actually contains D2B0/B2D0 tags with IccMultiProcessElementsTagDataEntry entries before selecting this conversion path.
  2. Use a profile that routes through the A2B (InitA) LUT path instead of the D2B multi-process path.
  3. Catch InvalidIccProfileException during converter construction and fall back to a supported profile.

Example fix

// before: passing a profile whose D2B0 tag is missing
var converter = new IccConverter(profile);
// after: verify the tag entry type first
if (profile.Tags.TryGetValue(IccProfileTag.D2B0, out var entry) && entry is IccMultiProcessElementsTagDataEntry)
{
    var converter = new IccConverter(profile);
}
Defensive patterns

Strategy: validation

Validate before calling

bool hasMpe = profile.Tags.TryGetValue(IccProfileTag.D2B0, out var e)
    && e is IccMultiProcessElementsTagDataEntry;
if (!hasMpe) { /* choose the A2B path or a different profile */ }

Type guard

if (profile.Tags.TryGetValue(IccProfileTag.D2B0, out var entry)
    && entry is IccMultiProcessElementsTagDataEntry mpe) { /* safe to use D2B path */ }

Prevention

When it happens

Trigger: Initializing a converter path that calls InitD (the D2B/B2D pipeline) for a profile where the D2Bx/B2Dx tag is missing entirely or contains a non-multiProcessElements entry (e.g. lut16).

Common situations: v4/v5 ICC profiles whose D2B tag was not written or was written as a legacy LUT entry; corrupt profile parsing that produced a different entry type for the tag.

Related errors


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

Appendix: source

Thrown at src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs:69

            ConversionMethod.ColorTrc => InitColorTrc(profile, toPcs),
            ConversionMethod.GrayTrc => InitGrayTrc(profile, toPcs),
            _ => throw new InvalidIccProfileException("Invalid conversion method."),
        };

    private static IVector4Calculator InitA(IccProfile profile, IccProfileTag tag)
        => GetTag(profile, tag) switch
        {
            IccLut8TagDataEntry lut8 => new LutEntryCalculator(lut8),
            IccLut16TagDataEntry lut16 => new LutEntryCalculator(lut16),
            IccLutAToBTagDataEntry lutAtoB => new LutABCalculator(lutAtoB),
            IccLutBToATagDataEntry lutBtoA => new LutABCalculator(lutBtoA),
            _ => throw new InvalidIccProfileException($"Invalid entry {tag}."),
        };

    private static IVector4Calculator InitD(IccProfile profile, IccProfileTag tag)
    {
        IccMultiProcessElementsTagDataEntry entry = GetTag<IccMultiProcessElementsTagDataEntry>(profile, tag)
            ?? throw new InvalidIccProfileException("Entry is null.");

        throw new NotImplementedException("Multi process elements are not supported");
    }

    private static ColorTrcCalculator InitColorTrc(IccProfile profile, bool toPcs)
    {
        IccXyzTagDataEntry redMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.RedMatrixColumn);
        IccXyzTagDataEntry greenMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.GreenMatrixColumn);
        IccXyzTagDataEntry blueMatrixColumn = GetTag<IccXyzTagDataEntry>(profile, IccProfileTag.BlueMatrixColumn);

        IccTagDataEntry redTrc = GetTag(profile, IccProfileTag.RedTrc);
        IccTagDataEntry greenTrc = GetTag(profile, IccProfileTag.GreenTrc);
        IccTagDataEntry blueTrc = GetTag(profile, IccProfileTag.BlueTrc);

        if (redMatrixColumn == null ||
            greenMatrixColumn == null ||
            blueMatrixColumn == null ||
            redTrc == null ||

View on GitHub (pinned to 59ce6af6fc)