SixLabors/ImageSharp · error · InvalidOperationException

Invalid calculation type

Error message

Invalid calculation type

What it means

LutABCalculator.Calculate switches over the LUT A-to-B / B-to-A processing layout type; the default arm throws InvalidOperationException("Invalid calculation type") when the entry's layout is not one of the supported LutAB layouts. This indicates the calculator was built from a LutAB entry whose class/type is unrecognized.

Solutions

  1. Re-export or replace the ICC profile using a standard tool so the lutA/BToB tags use standard classes (mBA, mAB, clut-only).
  2. Validate profile tags before conversion and skip/reject profiles with unknown LutAB classes.
  3. If the profile looks valid, report it as a library bug with the profile attached.
Defensive patterns

Strategy: try-catch

Try / catch

try { converter.Convert(...); }
catch (InvalidIccProfileException ex) { logger.LogWarning(ex, "Profile has unsupported LutAB layout"); /* reject or re-export profile */ }

Prevention

When it happens

Trigger: Calling Calculate (e.g. via the result path) on a LutABCalculator whose IccLutAtoBTagDataEntry has a ProcessElements/layout combination not handled during construction, leaving the layout switch with no matching case.

Common situations: ICC profiles containing non-standard or corrupted luta/btoA tag data whose class byte is out of the ICC-spec set; hand-edited profiles; library bug if a new ICC profile class wasn't mapped.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs:110

                if (this.curveMCalculator != null)
                {
                    value = this.curveMCalculator.Calculate(value);
                }

                if (this.clutCalculator != null)
                {
                    value = this.clutCalculator.Calculate(value);
                }

                if (this.curveACalculator != null)
                {
                    value = this.curveACalculator.Calculate(value);
                }

                return value;

            default:
                throw new InvalidOperationException("Invalid calculation type");
        }
    }

    /// <summary>
    /// Creates calculators for the processing stages present in the LUT entry.
    /// </summary>
    /// <remarks>
    /// The tag entry classes already validate channel continuity, so this method only materializes the available stages.
    /// </remarks>
    private void Init(IccTagDataEntry[] curveA, IccTagDataEntry[] curveB, IccTagDataEntry[] curveM, Vector3? matrix3x1, Matrix4x4? matrix3x3, IccClut clut)
    {
        bool hasACurve = curveA != null;
        bool hasBCurve = curveB != null;
        bool hasMCurve = curveM != null;
        bool hasMatrix = matrix3x1 != null && matrix3x3 != null;
        bool hasClut = clut != null;

        Guard.IsTrue(

View on GitHub (pinned to 59ce6af6fc)