Skip to main content

Automatically detect, split, and rotate multiple photos from scanned images

Project description

ScanSplitter Logo

ScanSplitter

PyPI Python versions License: GPLv3

Automatically detect, split, and rotate multiple photos from scanned images.

Drop a scan containing multiple photos and get individual, correctly-oriented images back.

ScanSplitter Screenshot

Quick Start

One-time setup - Install uv:

curl -LsSf https://astral.sh/uv/install.sh | sh

Run ScanSplitter (no clone needed):

uvx scansplitter api

Opens at http://localhost:8000 - drag & drop your scans and export cropped photos. If port 8000 is already in use, pick another:

uvx scansplitter api --port 8001

Features

  • Multiple detection modes - Choose between ScanSplitterv1, ScanSplitterv2 (default), and AI (U2-Net)
  • Interactive editing - Adjust, rotate, and resize bounding boxes before cropping
  • Auto-rotation - Detects and corrects 90°/180°/270° rotations
  • PDF support - Extract and process pages from PDF files
  • Web UI - Modern React interface with Fabric.js canvas editor
  • CLI - Batch process files from the command line

Detection Modes & Models

Photo detection (splitter)

  • ScanSplitterv2 (default): An improved contour-based detector. It applies contrast enhancement (CLAHE), adaptive thresholding, adaptive morphology (kernel scales with resolution), and contour quality filtering (solidity/aspect/extent). It can also use convex-hull borders for irregular edges.
  • ScanSplitterv1: The first contour-based detector used with adaptive threshold + fixed morphology + minAreaRect filtering. It’s simpler and can be useful as a fallback if v2 behaves unexpectedly on a specific scan.
  • AI (U2-Net): A deep-learning salient-object model (ONNX) that produces a mask; ScanSplitter then extracts regions from that mask. It’s best for difficult scans (busy backgrounds, low contrast), but requires downloading a model on first use. Might be less accurate for multiple photos at once.

Auto-rotation model

  • Orientation model: An EfficientNetV2-based ONNX classifier that predicts the correct 0°/90°/180°/270° rotation for each cropped photo. ScanSplitter may fall back to classic heuristics if the model can’t be loaded.

Model downloads

Some modes require downloading models on first use (U2-Net (5Mb / 176MB) and the orientation model (80MB)). The web UI shows download progress while this is happening.

Installation Options

Option 1: Run directly with uvx (recommended)

No installation needed - just run:

uvx scansplitter api

Option 2: Install with pipx

pipx install scansplitter
scansplitter api

Option 3: Install from source

git clone https://github.com/janklan/scansplitter
cd scansplitter
uv sync
uv run scansplitter api

Usage

Web Interface

scansplitter api
# or: uvx scansplitter api

Opens at http://localhost:8000 with:

  • Drag & drop file upload (images and PDFs)
  • Interactive bounding box editor (drag, resize, rotate)
  • Multi-file support with tabs
  • PDF page navigation
  • ZIP export

Command Line

# Process a scanned image
uv run scansplitter process scan.jpg -o ./output/

# Process a PDF
uv run scansplitter process document.pdf -o ./output/

# Multiple files
uv run scansplitter process scan1.jpg scan2.png -o ./output/

# Options
uv run scansplitter process scan.jpg \
  --no-rotate \
  --min-area 5 \
  --max-area 70 \
  --detection-mode scansplitterv2 \
  --format jpg \
  -o ./output/

CLI Options:

Option Description
-o, --output Output directory (default: ./output)
--no-rotate Disable auto-rotation
--min-area Minimum photo size as % of scan (default: 2)
--max-area Maximum photo size as % of scan (default: 80)
--detection-mode scansplitterv2 (default), scansplitterv1 (legacy), or u2net (deep learning); classic is an alias for scansplitterv2
--u2net-full Use full U2-Net model instead of lite (slower, more accurate)
--format Output format: png or jpg (default: png)

How It Works

  1. Photo detection - Runs the selected detection mode (ScanSplitterv1 / ScanSplitterv2 / AI (U2-Net)) to produce rotatable bounding boxes.
  2. Interactive adjustment - You can refine boxes in the web UI before cropping.
  3. Cropping - Extracts rotated regions using the adjusted boxes.
  4. Auto-rotation (optional) - Uses the orientation model (with fallbacks) to fix 90°/180°/270° rotations.

Credits

ScanSplitter depends on excellent open models and upstream work:

Development

Frontend Development

# Start API server
uv run scansplitter api --reload

# In another terminal, start frontend dev server
cd frontend
npm install
npm run dev

Frontend runs on http://localhost:5173 with hot reload, proxying API requests to :8000.

Build Frontend

cd frontend
npm run build

Builds to src/scansplitter/static/, which FastAPI serves automatically.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scansplitter-0.4.0.tar.gz (5.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scansplitter-0.4.0-py3-none-any.whl (5.0 MB view details)

Uploaded Python 3

File details

Details for the file scansplitter-0.4.0.tar.gz.

File metadata

  • Download URL: scansplitter-0.4.0.tar.gz
  • Upload date:
  • Size: 5.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for scansplitter-0.4.0.tar.gz
Algorithm Hash digest
SHA256 56e92ba20b4fb7c84e8486c0d902008604c7eace8ab9f4461a94e819823ab5a0
MD5 ce5e0dfa802582814460b3393caa875b
BLAKE2b-256 2f0183b2cff4dc6c0a8cb9b677e10a55872a21610c5de1230fc5890bbe122437

See more details on using hashes here.

File details

Details for the file scansplitter-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: scansplitter-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for scansplitter-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8039fa2646105c09c156bf010cb8b8e9a643e8b04309da0af81fe33d2b5da57
MD5 3015d5a63323dd4120c67ac1de0cecf0
BLAKE2b-256 18d784a6f92c107c5cef5fa6cad3ef7ecef5af143ed9e75e6afbc1f914db7066

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page