{"record":{"id":"ee5ebd32320459d7","repo":"SixLabors/ImageSharp","slug":"source-pcs-sourceparams-pcstype-is-not-supported","errorCode":null,"errorMessage":"Source PCS {sourceParams.PcsType} is not supported","messagePattern":"Source PCS (.+?) is not supported","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs","lineNumber":384,"sourceCode":"        ColorProfileConverter pcsConverter)\n    {\n        // all conversions are funneled through XYZ in case PCS adjustments need to be made\n        CieXyz xyz;\n\n        switch (sourceParams.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 to modern v4 encoding when returned from a 16-bit LUT\n            case IccColorSpaceType.CieLab:\n                sourcePcs = sourceParams.Is16BitLutEntry ? LabV2ToLab(sourcePcs) : sourcePcs;\n                CieLab lab = CieLab.FromScaledVector4(sourcePcs);\n                xyz = pcsConverter.Convert<CieLab, CieXyz>(in lab);\n                break;\n            case IccColorSpaceType.CieXyz:\n                xyz = CieXyz.FromScaledVector4(sourcePcs);\n                break;\n            default:\n                throw new ArgumentOutOfRangeException($\"Source PCS {sourceParams.PcsType} is not supported\");\n        }\n\n        bool oneProfileHasV2PerceptualAdjustment = sourceParams.HasV2PerceptualHandling ^ targetParams.HasV2PerceptualHandling;\n\n        // when converting from device to PCS with v2 perceptual intent\n        // the black point needs to be adjusted to v4 after converting the PCS values\n        if (sourceParams.HasNoPerceptualHandling ||\n            (oneProfileHasV2PerceptualAdjustment && sourceParams.HasV2PerceptualHandling))\n        {\n            Vector3 vector = xyz.ToVector3();\n\n            // when using LAB PCS, negative values are clipped before PCS adjustment (in DemoIccMAX)\n            if (sourceParams.PcsType == IccColorSpaceType.CieLab)\n            {\n                vector = Vector3.Max(vector, Vector3.Zero);\n            }\n\n            xyz = new CieXyz(AdjustPcsFromV2BlackPoint(vector));","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs#L366-L402","documentation":"GetTargetPcsWithPerceptualAdjustment (single-value path) decodes the source PCS value but found a source PCS type other than CieLab or CieXYZ. Perceptual-intent conversion with v2 black-point compensation only supports those two PCS encodings, so an unexpected signature triggers ArgumentOutOfRangeException.","triggerScenarios":"ConvertUsingIccProfile with rendering intent Perceptual where the source profile header declares a PCS color space other than XYZ or CIELab.","commonSituations":"Profiles with damaged headers; custom/proprietary profiles reusing PCS slots; misparsed profile bytes shifting the PCS signature field.","solutions":["Verify the source profile's PCS signature is 'XYZ ' or 'Lab ' and replace the profile if not.","Regenerate the profile with a compliant tool.","Use a different rendering intent that avoids the perceptual adjustment path if the profiles allow it."],"exampleFix":"// before\nvar options = new ColorConversionOptions\n{\n    SourceIccProfile = corruptProfile, // PCS signature invalid\n    TargetIccProfile = target,\n    RenderingIntent = RenderingIntent.Perceptual\n};\n\n// after\nvar options = new ColorConversionOptions\n{\n    SourceIccProfile = IccProfile.Parse(File.ReadAllBytes(\"valid.icc\")),\n    TargetIccProfile = target,\n    RenderingIntent = RenderingIntent.Perceptual\n};","handlingStrategy":"validation","validationCode":"bool supported = sourceProfile.Header.ColorSpace is IccColorSpaceType.CieXyz or IccColorSpaceType.CieLab;\nif (!supported) throw new InvalidOperationException(\"Unsupported source PCS for perceptual intent.\");","typeGuard":"bool HasKnownSourcePcs(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(\"Source PCS\"))\n{ /* replace profile or use different intent */ }","preventionTips":["Check the profile version and PCS signature when perceptual intent is selected.","Avoid perceptual intent with unvetted profiles.","Keep a curated whitelist of accepted source profiles."],"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"}