{"record":{"id":"a66d16b2804bef03","repo":"ocrmypdf/OCRmyPDF","slug":"redo-ocr-or-mode-redo-is-not-currently-compa","errorCode":null,"errorMessage":"--redo-ocr (or --mode redo) is not currently compatible with --deskew, --clean-final, and --remove-background","messagePattern":"--redo-ocr \\(or --mode redo\\) is not currently compatible with --deskew, --clean-final, and --remove-background","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/ocrmypdf/_options.py","lineNumber":465,"sourceCode":"    def validate_redo_ocr_options(self):\n        \"\"\"Validate options compatible with redo mode.\"\"\"\n        if self.mode == ProcessingMode.redo and (\n            self.deskew or self.clean_final or self.remove_background\n        ):\n            raise ValueError(\n                \"--redo-ocr (or --mode redo) is not currently compatible with \"\n                \"--deskew, --clean-final, and --remove-background\"\n            )\n        return self\n\n    @model_validator(mode='after')\n    def validate_output_type_compatibility(self):\n        \"\"\"Validate output type is compatible with output file.\"\"\"\n        if self.output_type == 'none' and str(self.output_file) not in (\n            os.devnull,\n            '-',\n        ):\n            raise ValueError(\n                \"Since you specified `--output-type none`, the output file \"\n                f\"{str(self.output_file)} cannot be produced. Set the output file to \"\n                f\"`-` to suppress this message.\"\n            )\n        return self\n\n    @property\n    def lossless_reconstruction(self):\n        \"\"\"Determine lossless_reconstruction based on other options.\"\"\"\n        lossless = not any(\n            [\n                self.deskew,\n                self.clean_final,\n                self.mode == ProcessingMode.force,\n                self.remove_background,\n            ]\n        )\n        return lossless","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/_options.py#L447-L483","documentation":"Raised when --redo-ocr/--mode redo is combined with --deskew, --clean-final, or --remove-background. These preprocessing options rasterize pages, which conflicts with redo mode's goal of identifying and re-OCRing only existing text without destroying vector content.","triggerScenarios":"Passing both --redo-ocr (or --mode redo) and any of --deskew, --clean-final, or --remove-background on the CLI or via OcrOptions; validated during options checking before processing starts.","commonSituations":"Users upgrading scripts that combined cleanup flags with redo mode; copying flag sets from older ocrmypdf versions or forum examples.","solutions":["Drop --deskew/--clean-final/--remove-background when using --redo-ocr","Switch to --force-ocr if rasterizing preprocessing is more important than preserving the original page content","Run two passes: first --mode redo, then a separate pass with preprocessing on the output"],"exampleFix":"# before\nocrmypdf --redo-ocr --deskew in.pdf out.pdf\n# after\nocrmypdf --redo-ocr in.pdf out.pdf","handlingStrategy":"validation","validationCode":"redo_conflicts = ['deskew','clean_final','remove_background']\nif opts.mode == 'redo' and any(getattr(opts, f) for f in redo_conflicts):\n    raise SystemExit('redo mode forbids deskew/clean-final/remove-background')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep mode-specific flag sets in named CLI profiles instead of one long command"],"tags":["ocr","cli-arguments","option-compatibility","ocrmypdf"],"backgroundTag":"incompatible-cli-options","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}