# rocketraman/sane-scan-pdf architecture

> Architecture diagram of the GitHub repository rocketraman/sane-scan-pdf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rocketraman/sane-scan-pdf
- Repository: https://github.com/rocketraman/sane-scan-pdf

## Overview

SANE Command-Line Scan to PDF is a Bash tool for acquiring scanner pages and producing combined or per-page PDFs. The documented workflow starts with CLI options and configuration, scans through SANE, post-processes pages, assembles PDFs, and optionally adds searchable OCR or opens the result. Scanner acquisition and page processing can run in parallel. The tree contains `scan` and `scan_perpage`, but no source excerpts were supplied, so internal call wiring is limited to relationships documented in the README; optional tools are shown separately.

Main entry points: [`scan`](https://github.com/rocketraman/sane-scan-pdf/blob/master/scan) (Scan command), [`scan_perpage`](https://github.com/rocketraman/sane-scan-pdf/blob/master/scan_perpage) (Per-page command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and configuration"]
  node_scan["Scan command"]
  node_option_config["Option groups"]
end

subgraph group_acquisition["Scan acquisition"]
  node_scan_perpage["Per-page command"]
  node_sane["SANE scanner"]
end

subgraph group_processing["Page processing"]
  node_page_images["Scanned pages"]
  node_unpaper["Unpaper deskew"]
  node_imagemagick["Image processing"]
  node_bc["Threshold calculation"]
end

subgraph group_output["PDF output"]
  node_pnmtops["Image conversion"]
  node_ps2pdf["PDF conversion"]
  node_pdfunite["PDF assembly"]
  node_tesseract["OCR engine"]
  node_pdf["PDF output"]
  node_viewer["PDF viewer"]
  node_xdg_open["xdg-open"]
end

node_user(("CLI user"))

node_user -->|"runs"| node_scan
node_scan -->|"reads"| node_option_config
node_scan -->|"scans"| node_sane
node_scan -->|"dispatches"| node_scan_perpage
node_sane -->|"produces"| node_page_images
node_scan -.->|"deskews with"| node_unpaper
node_scan -.->|"processes with"| node_imagemagick
node_scan -.->|"calculates with"| node_bc
node_scan -->|"converts with"| node_pnmtops
node_scan -->|"converts with"| node_ps2pdf
node_scan -->|"joins with"| node_pdfunite
node_scan -.->|"runs OCR with"| node_tesseract
node_scan -.->|"opens via"| node_xdg_open
node_page_images -->|"converts"| node_pnmtops
node_pnmtops -->|"feeds"| node_ps2pdf
node_ps2pdf -->|"feeds"| node_pdfunite
node_pdfunite -->|"produces"| node_pdf
node_tesseract -.->|"adds searchable text"| node_pdf
node_pdf -.->|"opens in"| node_xdg_open
node_xdg_open -.->|"launches"| node_viewer

click node_scan "https://github.com/rocketraman/sane-scan-pdf/blob/master/scan"
click node_scan_perpage "https://github.com/rocketraman/sane-scan-pdf/blob/master/scan_perpage"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_scan,node_option_config,node_user toneBlue
class node_scan_perpage,node_sane toneAmber
class node_page_images,node_unpaper,node_imagemagick,node_bc toneMint
class node_pnmtops,node_ps2pdf,node_pdfunite,node_tesseract,node_pdf,node_viewer,node_xdg_open toneRose
```

## Components

### CLI and configuration

- [Scan command](https://github.com/rocketraman/sane-scan-pdf/blob/master/scan): `scan`
- **Option groups**

### Scan acquisition

- [Per-page command](https://github.com/rocketraman/sane-scan-pdf/blob/master/scan_perpage): `scan_perpage`
- **SANE scanner**

### Page processing

- **Scanned pages**
- **Unpaper deskew**
- **Image processing**
- **Threshold calculation**

### PDF output

- **Image conversion**
- **PDF conversion**
- **PDF assembly**
- **OCR engine**
- **PDF output**
- **PDF viewer**
- **xdg-open**

### Other components

- **CLI user**

## Connections

- CLI user → Scan command: runs
- Scan command → Option groups: reads
- Scan command → SANE scanner: scans
- Scan command → Per-page command: dispatches
- SANE scanner → Scanned pages: produces
- Scan command → Unpaper deskew: deskews with
- Scan command → Image processing: processes with
- Scan command → Threshold calculation: calculates with
- Scan command → Image conversion: converts with
- Scan command → PDF conversion: converts with
- Scan command → PDF assembly: joins with
- Scan command → OCR engine: runs OCR with
- Scan command → xdg-open: opens via
- Scanned pages → Image conversion: converts
- Image conversion → PDF conversion: feeds
- PDF conversion → PDF assembly: feeds
- PDF assembly → PDF output: produces
- OCR engine → PDF output: adds searchable text
- PDF output → xdg-open: opens in
- xdg-open → PDF viewer: launches
