SixLabors/ImageSharp · error · InvalidIccProfileException
ICC conversion supports at most four input and output…
Error message
ICC conversion supports at most four input and output channels.
What it means
ClutCalculator's constructor rejects ICC CLUT (color lookup table) entries with more than 4 input or output channels by throwing InvalidIccProfileException. The calculator's internal Vector4-based processing only supports up to four channels per side, as used by ICC device spaces like RGB and CMYK.
Solutions
- Replace the ICC profile with one from a trusted source / re-exported from a standard tool (Photoshop, littleCMS).
- Validate the profile's CLUT channel counts before conversion and reject profiles with >4 channels.
- If N-channel support is genuinely needed, it is unsupported by this converter; pre-convert the image with an external ICC engine.
Example fix
// before
var calc = new ClutCalculator(profile.Clut); // may throw
// after
if (profile.Clut.InputChannelCount > 4 || profile.Clut.OutputChannelCount > 4)
{
throw new NotSupportedException("Profile uses more than 4 CLUT channels.");
}
var calc = new ClutCalculator(profile.Clut); Defensive patterns
Strategy: validation
Validate before calling
if (clut.InputChannelCount > 4 || clut.OutputChannelCount > 4)
{
throw new NotSupportedException("ICC profile CLUT exceeds 4 channels; unsupported.");
} Try / catch
try { converter.Convert(...); }
catch (InvalidIccProfileException ex) { logger.LogWarning(ex, "Profile has unsupported CLUT channel counts"); /* fall back to sRGB assumption */ } Prevention
- Only accept ICC profiles from trusted sources / re-export with standard tools.
- Validate CLUT channel counts during profile intake.
- Treat N-channel (>CMYK) profiles as unsupported and route them to an external ICC engine.
When it happens
Trigger: Constructing a ClutCalculator (directly or via LutEntryCalculator) from an IccClut whose InputChannelCount or OutputChannelCount exceeds 4 — typically a malformed or hand-crafted ICC profile with more device channels than any supported space.
Common situations: Loading a corrupt or non-standard ICC profile from the wild; profiles edited or truncated by third-party tools; profiles for exotic N-channel device spaces beyond CMYK.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid calculation type
- ICC conversion supports at most four input and output…
- ParametricCurve
- ICC conversion supports at most four tone response curves.
- Invalid Entry.
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/1fc821496f6b9a1f.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/ColorProfiles/Icc/Calculators/ClutCalculator.cs:47
private readonly uint[] nPower;
private int n000;
private int n001;
private int n010;
private int n011;
private int n100;
private int n101;
private int n110;
private int n111;
private int n1000;
public ClutCalculator(IccClut clut)
{
Guard.NotNull(clut, nameof(clut));
Guard.MustBeGreaterThan(clut.InputChannelCount, 0, nameof(clut.InputChannelCount));
Guard.MustBeGreaterThan(clut.OutputChannelCount, 0, nameof(clut.OutputChannelCount));
if (clut.InputChannelCount > 4 || clut.OutputChannelCount > 4)
{
throw new InvalidIccProfileException("ICC conversion supports at most four input and output channels.");
}
this.inputCount = clut.InputChannelCount;
this.outputCount = clut.OutputChannelCount;
this.g = new float[this.inputCount];
this.ig = new uint[this.inputCount];
this.s = new float[this.inputCount];
this.nPower = new uint[16];
this.lut = clut.Values;
this.nodeCount = (int)Math.Pow(2, clut.InputChannelCount);
this.df = new float[this.nodeCount];
this.nodes = new float[this.nodeCount][];
this.dimSize = new int[this.inputCount];
this.gridPointCount = clut.GridPointCount;
this.maxGridPoint = new byte[this.inputCount];
for (int i = 0; i < this.inputCount; i++)
{
this.maxGridPoint[i] = (byte)(this.gridPointCount[i] - 1);View on GitHub (pinned to 59ce6af6fc)