pagescan.scan#

pagescan.scan(image_path, output_path=None, config=None)[source]#

Scan a single document photo into a clean PDF.

Pipeline:
  1. Load image

  2. Detect corners (ML with validation, or conservative crop)

  3. Perspective transform or direct crop

  4. Auto-rotate (OCR-based orientation correction)

  5. Deskew (Hough-based text tilt correction)

  6. Shadow removal + white balance

  7. Scan-like enhancement (grayscale, contrast, sharpen)

  8. Place on canvas (A4) and save as PDF

Parameters:
  • image_path (str) – Path to input image (JPEG, PNG, TIFF).

  • output_path (str | None) – Path for output PDF. If None, replaces extension with .pdf.

  • config (ScanConfig | None) – Scan configuration. Uses defaults if None.

Returns:

success, quality_score, quality_passed, message, output_path.

Return type:

dict