{"record":{"id":"802edc86984b9e24","repo":"SixLabors/ImageSharp","slug":"target-pcs-targetparams-pcstype-is-not-supported","errorCode":null,"errorMessage":"Target PCS {targetParams.PcsType} is not supported","messagePattern":"Target PCS (.+?) is not supported","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs","lineNumber":432,"sourceCode":"            {\n                vector = Vector3.Max(vector, Vector3.Zero);\n            }\n\n            xyz = new CieXyz(vector);\n        }\n\n        switch (targetParams.PcsType)\n        {\n            // 16-bit Lab encodings changed from v2 to v4, but 16-bit LUTs always use the legacy encoding regardless of version\n            // so convert Lab back to legacy encoding before using in a 16-bit LUT\n            case IccColorSpaceType.CieLab:\n                CieLab lab = pcsConverter.Convert<CieXyz, CieLab>(in xyz);\n                Vector4 targetPcs = lab.ToScaledVector4();\n                return targetParams.Is16BitLutEntry ? LabToLabV2(targetPcs) : targetPcs;\n            case IccColorSpaceType.CieXyz:\n                return xyz.ToScaledVector4();\n            default:\n                throw new ArgumentOutOfRangeException($\"Target PCS {targetParams.PcsType} is not supported\");\n        }\n    }\n\n    /// <summary>\n    /// Effectively this is <see cref=\"GetTargetPcsWithoutAdjustment(Span{Vector4}, ConversionParams, ConversionParams, ColorProfileConverter)\"/> with an extra step in the middle.\n    /// It adjusts PCS by compensating for the black point used for perceptual intent in v2 profiles.\n    /// The adjustment needs to be performed in XYZ space, potentially an overhead of 2 more conversions.\n    /// Not required if both spaces need V2 correction, since they both have the same understanding of the PCS.\n    /// Not compatible with PCS adjustment for absolute intent.\n    /// </summary>\n    /// <param name=\"pcs\">The PCS values from the source.</param>\n    /// <param name=\"sourceParams\">The source profile parameters.</param>\n    /// <param name=\"targetParams\">The target profile parameters.</param>\n    /// <param name=\"pcsConverter\">The converter to use for the PCS adjustments.</param>\n    /// <exception cref=\"ArgumentOutOfRangeException\">Thrown when the source or target PCS is not supported.</exception>\n    private static void GetTargetPcsWithPerceptualAdjustment(\n        Span<Vector4> pcs,\n        ConversionParams sourceParams,","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs#L414-L450","documentation":"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.","triggerScenarios":"ConvertUsingIccProfile (perceptual intent / v2 adjustment active) where the TARGET profile's PCS color space signature is unsupported.","commonSituations":"Target profile written by a nonconforming tool; truncated or byte-swapped profile data producing a bogus PCS field.","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."],"exampleFix":"// before\noptions.TargetIccProfile = suspiciousProfile; // PCS field corrupt\n\n// after\noptions.TargetIccProfile = IccProfile.Parse(File.ReadAllBytes(\"sRGB.icc\"));","handlingStrategy":"validation","validationCode":"bool supported = targetProfile.Header.ColorSpace is IccColorSpaceType.CieXyz or IccColorSpaceType.CieLab;\nif (!supported) throw new InvalidOperationException(\"Unsupported target PCS.\");","typeGuard":"bool HasKnownTargetPcs(ConversionParams p) => p.PcsType is IccColorSpaceType.CieXyz or IccColorSpaceType.CieLab;","tryCatchPattern":"try { return converter.ConvertUsingIccProfile<TFrom, TTo>(in color); }\ncatch (ArgumentOutOfRangeException ex) when (ex.Message.Contains(\"Target PCS\"))\n{ /* swap target profile */ }","preventionTips":["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."],"tags":["icc","pcs","perceptual-intent","argument-out-of-range"],"backgroundTag":"invalid-enum-value","analyzedSha":"59ce6af6fc29027cda277ef62d4d1694a8acce91","analyzedAt":"2026-09-13T18:34:59.331Z","contentChangedAt":"2026-09-13T18:34:59.331Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}