{"record":{"id":"429413a2ab7c4d46","repo":"ocrmypdf/OCRmyPDF","slug":"remove-background-is-temporarily-not-implemented","errorCode":null,"errorMessage":"--remove-background is temporarily not implemented","messagePattern":"--remove-background is temporarily not implemented","errorType":"error_code","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"src/ocrmypdf/_pipeline.py","lineNumber":627,"sourceCode":"        input_file=input_file,\n        output_file=output_file,\n        raster_device=device,\n        raster_dpi=canvas_dpi,\n        page_dpi=page_dpi,\n        pageno=pageinfo.pageno + 1,\n        rotation=correction,\n        filter_vector=remove_vectors,\n        stop_on_soft_error=not page_context.options.continue_on_soft_render_error,\n        options=page_context.options,\n        use_cropbox=False,\n    )\n    return output_file\n\n\ndef preprocess_remove_background(input_file: Path, page_context: PageContext) -> Path:\n    \"\"\"Remove the background from the input image (temporarily disabled).\"\"\"\n    if any(image.bpc > 1 for image in page_context.pageinfo.images):\n        raise NotImplementedError(\"--remove-background is temporarily not implemented\")\n        # output_file = page_context.get_path('pp_rm_bg.png')\n        # leptonica.remove_background(input_file, output_file)\n        # return output_file\n    log.info(\"background removal skipped on mono page\")\n    return input_file\n\n\ndef preprocess_deskew(input_file: Path, page_context: PageContext) -> Path:\n    \"\"\"Deskews the input image using the OCR engine and saves the output to a file.\n\n    Args:\n        input_file: The input image file to deskew.\n        page_context: The context of the page being processed.\n\n    Returns:\n        Path: The path to the deskewed image file.\n    \"\"\"\n    output_file = page_context.get_path('pp_deskew.png')","sourceCodeStart":609,"sourceCodeEnd":645,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/_pipeline.py#L609-L645","documentation":"Raised because background removal is temporarily unimplemented: when any image on the page has bpc > 1 (grayscale/color), --remove-background raises NotImplementedError. The leptonica call is commented out in the source.","triggerScenarios":"Passing --remove-background on a page containing grayscale or color images (bpc > 1); mono pages skip removal with a log message instead.","commonSituations":"Users with old scripts or docs referencing --remove-background; upgrading ocrmypdf versions where the feature was disabled.","solutions":["Remove --remove-background from your command","Do background cleanup externally beforehand (e.g. ImageMagick/leptonica -level, scan preprocessing tools)"],"exampleFix":"# before\nocrmypdf --remove-background in.pdf out.pdf\n# after\nocrmypdf in.pdf out.pdf","handlingStrategy":"validation","validationCode":"if getattr(opts, 'remove_background', False):\n    raise SystemExit('--remove-background is not implemented; remove the flag')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin an ocrmypdf version whose flag set you've tested; scrub deprecated flags on upgrade"],"tags":["ocr","ocrmypdf","not-implemented","preprocessing"],"backgroundTag":"feature-not-implemented","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}