SixLabors/ImageSharp · error · ArgumentOutOfRangeException
Target PCS is not supported
Error message
Target PCS {targetParams.PcsType} is not supported What it means
In the same perceptual-adjustment path, the target side switch only handles CieLab and CieXYZ; any other target PCS signature reaches the default arm and throws ArgumentOutOfRangeException naming the target profile's PCS type.
Solutions
- Check the target profile header's PCS field; re-export the profile so it uses XYZ or Lab PCS.
- Swap in a known-good standard profile (sRGB/AdobeRGB) as the target.
- Validate profiles at load time with an ICC validator before configuring conversion.
Example fix
// before
options.TargetIccProfile = suspiciousProfile; // PCS field corrupt
// after
options.TargetIccProfile = IccProfile.Parse(File.ReadAllBytes("sRGB.icc")); Defensive patterns
Strategy: validation
Validate before calling
bool supported = targetProfile.Header.ColorSpace is IccColorSpaceType.CieXyz or IccColorSpaceType.CieLab;
if (!supported) throw new InvalidOperationException("Unsupported target PCS."); Type guard
bool HasKnownTargetPcs(ConversionParams p) => p.PcsType is IccColorSpaceType.CieXyz or IccColorSpaceType.CieLab;
Try / catch
try { return converter.ConvertUsingIccProfile<TFrom, TTo>(in color); }
catch (ArgumentOutOfRangeException ex) when (ex.Message.Contains("Target PCS"))
{ /* swap target profile */ } Prevention
- Validate target profile headers at configuration time.
- Use standard output profiles (sRGB/AdobeRGB) whenever possible.
- Re-export custom profiles with littleCMS/iccMAX if headers look unusual.
When it happens
Trigger: ConvertUsingIccProfile (perceptual intent / v2 adjustment active) where the TARGET profile's PCS color space signature is unsupported.
Common situations: Target profile written by a nonconforming tool; truncated or byte-swapped profile data producing a bogus PCS field.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Source PCS is not supported
- Source PCS to target PCS is not supported
- maxDegreeOfParallelism
- Unsupported color hex format.
- Source ICC profile is missing.
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/802edc86984b9e24.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs:432
{
vector = Vector3.Max(vector, Vector3.Zero);
}
xyz = new CieXyz(vector);
}
switch (targetParams.PcsType)
{
// 16-bit Lab encodings changed from v2 to v4, but 16-bit LUTs always use the legacy encoding regardless of version
// so convert Lab back to legacy encoding before using in a 16-bit LUT
case IccColorSpaceType.CieLab:
CieLab lab = pcsConverter.Convert<CieXyz, CieLab>(in xyz);
Vector4 targetPcs = lab.ToScaledVector4();
return targetParams.Is16BitLutEntry ? LabToLabV2(targetPcs) : targetPcs;
case IccColorSpaceType.CieXyz:
return xyz.ToScaledVector4();
default:
throw new ArgumentOutOfRangeException($"Target PCS {targetParams.PcsType} is not supported");
}
}
/// <summary>
/// Effectively this is <see cref="GetTargetPcsWithoutAdjustment(Span{Vector4}, ConversionParams, ConversionParams, ColorProfileConverter)"/> with an extra step in the middle.
/// It adjusts PCS by compensating for the black point used for perceptual intent in v2 profiles.
/// The adjustment needs to be performed in XYZ space, potentially an overhead of 2 more conversions.
/// Not required if both spaces need V2 correction, since they both have the same understanding of the PCS.
/// Not compatible with PCS adjustment for absolute intent.
/// </summary>
/// <param name="pcs">The PCS values from the source.</param>
/// <param name="sourceParams">The source profile parameters.</param>
/// <param name="targetParams">The target profile parameters.</param>
/// <param name="pcsConverter">The converter to use for the PCS adjustments.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the source or target PCS is not supported.</exception>
private static void GetTargetPcsWithPerceptualAdjustment(
Span<Vector4> pcs,
ConversionParams sourceParams,View on GitHub (pinned to 59ce6af6fc)