{"record":{"id":"27a43864bff70eb9","repo":"SixLabors/ImageSharp","slug":"source-pcs-sourceparams-pcstype-to-target-pcs-targetparams","errorCode":null,"errorMessage":"Source PCS {sourceParams.PcsType} to target PCS {targetParams.PcsType} is not supported","messagePattern":"Source PCS (.+?) to target PCS (.+?) is not supported","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs","lineNumber":241,"sourceCode":"                // if both source and target LUT use same v2 LAB encoding, no need to correct them\n                if (sourceParams.Is16BitLutEntry && targetParams.Is16BitLutEntry)\n                {\n                    CieLab sourceLab = CieLab.FromScaledVector4(sourcePcs);\n                    CieLab targetLab = pcsConverter.Convert<CieLab, CieLab>(in sourceLab);\n                    return targetLab.ToScaledVector4();\n                }\n                else\n                {\n                    sourcePcs = sourceParams.Is16BitLutEntry ? LabV2ToLab(sourcePcs) : sourcePcs;\n                    CieLab sourceLab = CieLab.FromScaledVector4(sourcePcs);\n                    CieLab targetLab = pcsConverter.Convert<CieLab, CieLab>(in sourceLab);\n                    Vector4 targetPcs = targetLab.ToScaledVector4();\n                    return targetParams.Is16BitLutEntry ? LabToLabV2(targetPcs) : targetPcs;\n                }\n            }\n\n            default:\n                throw new ArgumentOutOfRangeException($\"Source PCS {sourceParams.PcsType} to target PCS {targetParams.PcsType} is not supported\");\n        }\n    }\n\n    private static void GetTargetPcsWithoutAdjustment(\n        Span<Vector4> pcs,\n        ConversionParams sourceParams,\n        ConversionParams targetParams,\n        ColorProfileConverter pcsConverter)\n    {\n        // Profile connecting spaces can only be Lab, XYZ.\n        // 16-bit Lab encodings changed from v2 to v4, but 16-bit LUTs always use the legacy encoding regardless of version\n        // so ensure that Lab is using the correct encoding when a 16-bit LUT is used\n        switch (sourceParams.PcsType)\n        {\n            // Convert from Lab to XYZ.\n            case IccColorSpaceType.CieLab when targetParams.PcsType is IccColorSpaceType.CieXyz:\n            {\n                if (sourceParams.Is16BitLutEntry)","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/SixLabors/ImageSharp/blob/59ce6af6fc29027cda277ef62d4d1694a8acce91/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs#L223-L259","documentation":"GetTargetPcsWithoutAdjustment (single-value path) switches on the PCS color space recorded in the source profile's ConversionParams; the default arm throws because that combination of source/target PCS types has no implemented conversion route. ICC profiles use either XYZ or CIELab as PCS, and only specific pairs are supported for this intent.","triggerScenarios":"Calling ConvertUsingIccProfile where the source profile's PCS color space signature (from profile header) is something other than the supported CieXYZ/CieLab cases for the non-perceptual path — e.g. a malformed or exotic profile header, or a PCS pair that falls through all switch cases.","commonSituations":"Using hand-edited, corrupt, or nonstandard ICC profiles; profiles generated by tools that write unusual PCS signatures; testing with stub profiles.","solutions":["Inspect both profiles' header PCS fields (data color space / PCS illuminant signature) and use standard profiles (v2/v4 sRGB, AdobeRGB) whose PCS is XYZ or Lab.","Re-export or fix the offending profile with a standards-compliant tool (e.g. littleCMS, iccMAX).","If you believe the PCS pair should be supported, verify profile version and intent — some pairs are only implemented for perceptual handling."],"exampleFix":"// before\nvar bad = new IccProfile(); // header PCS unsupported\noptions.SourceIccProfile = bad;\n\n// after\nvar options = new ColorConversionOptions\n{\n    SourceIccProfile = IccProfile.Parse(File.ReadAllBytes(\"sRGB v4.icc\")), // standard XYZ PCS\n    TargetIccProfile = target\n};","handlingStrategy":"validation","validationCode":"IccColorSpaceType pcs = sourceProfile.Header.ColorSpace; // verify PCS field\nbool ok = pcs is IccColorSpaceType.CieXyz or IccColorSpaceType.CieLab;","typeGuard":"bool HasKnownPcs(IccProfile p) => p.Header.ColorSpace is IccColorSpaceType.CieXyz or IccColorSpaceType.CieLab;","tryCatchPattern":"try { return converter.ConvertUsingIccProfile<TFrom, TTo>(in color); }\ncatch (ArgumentOutOfRangeException ex)\n{ log.Warn(ex, \"Unsupported PCS pair\"); return fallbackConversion(color); }","preventionTips":["Only use profiles from trusted, standards-compliant generators.","Check header PCS signatures when loading profiles.","Prefer bundled standard v2/v4 profiles over third-party or hand-edited ones."],"tags":["icc","pcs","color-management","argument-out-of-range","unsupported-profile"],"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"}