{"record":{"id":"7fa33effd2d4dece","repo":"ocrmypdf/OCRmyPDF","slug":"invalid-color-conversion-strategy-options-ghosts","errorCode":null,"errorMessage":"Invalid color conversion strategy: {options.ghostscript.color_conversion_strategy}","messagePattern":"Invalid color conversion strategy: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/ocrmypdf/builtin_plugins/ghostscript.py","lineNumber":227,"sourceCode":"                \"(or --mode force) to discard existing text.\"\n            )\n        if ghostscript.jpeg_truncation_bug(gs_version):\n            log.warning(\n                \"Ghostscript %s contains JPEG encoding errors that may corrupt \"\n                \"images. OCRmyPDF will attempt to mitigate, but this version is \"\n                \"strongly not recommended. Please upgrade to Ghostscript %s or \"\n                \"later, which fixes this.\",\n                gs_version,\n                ghostscript.GS_JPEG_TRUNCATION_FIXED,\n            )\n        if options.output_type == 'pdfa':\n            options.output_type = 'pdfa-2'\n\n    if (\n        options.ghostscript.color_conversion_strategy\n        not in ghostscript.COLOR_CONVERSION_STRATEGIES\n    ):\n        raise ValueError(\n            f\"Invalid color conversion strategy: \"\n            f\"{options.ghostscript.color_conversion_strategy}\"\n        )\n    if (\n        options.ghostscript.pdfa_image_compression != 'auto'\n        and options.output_type not in ('auto', 'pdfa', 'pdfa-1', 'pdfa-2', 'pdfa-3')\n    ):\n        log.warning(\n            \"--pdfa-image-compression argument only applies when \"\n            \"--output-type is 'auto' or one of 'pdfa', 'pdfa-1', 'pdfa-2', 'pdfa-3'\"\n        )\n\n\n@hookimpl\ndef rasterize_pdf_page(\n    input_file,\n    output_file,\n    raster_device,","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/builtin_plugins/ghostscript.py#L209-L245","documentation":"Ghostscript's color conversion strategy must be one of the values Ghostscript supports (ghostscript.COLOR_CONVERSION_STRATEGIES, e.g. LeaveColorUnchanged, RGB, CMYK, Gray ...). check_options() validates options.ghostscript.color_conversion_strategy and raises ValueError for anything else.","triggerScenarios":"Setting the kwarg path ghostscript={'color_conversion_strategy': 'leave_color_unchanged'} (wrong spelling/case) or a nonexistent strategy string.","commonSituations":"Copying strategy names from old blog posts or CLI flags with underscores instead of CamelCase; typos like 'RGB ' with trailing whitespace.","solutions":["Use one of the exact supported names, e.g. 'LeaveColorUnchanged', 'RGB', 'Gray', 'CMYK', 'UseDeviceIndependentColor' (check ghostscript.COLOR_CONVERSION_STRATEGIES for your version).","Confirm the option is nested under the ghostscript sub-namespace, not passed as a top-level kwarg."],"exampleFix":"# before\nocr(in, out, ghostscript={'color_conversion_strategy': 'leaveunchanged'})\n# after\nocr(in, out, ghostscript={'color_conversion_strategy': 'LeaveColorUnchanged'})","handlingStrategy":"validation","validationCode":"from ocrmypdf.builtin_plugins.ghostscript import COLOR_CONVERSION_STRATEGIES\nassert strategy in COLOR_CONVERSION_STRATEGIES","typeGuard":"def is_valid_color_strategy(s: str) -> bool:\n    from ocrmypdf.builtin_plugins.ghostscript import COLOR_CONVERSION_STRATEGIES\n    return s in COLOR_CONVERSION_STRATEGIES","tryCatchPattern":null,"preventionTips":["Always source strategy names from COLOR_CONVERSION_STRATEGIES rather than hardcoding strings.","Use exact CamelCase values like 'LeaveColorUnchanged'."],"tags":["ocrmypdf","ghostscript","color-conversion","validation"],"backgroundTag":"invalid-option-value","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}