signature-improver
Fast, robust signature enhancement — for the command line and the Python ecosystem.
Isolate the strokes, remove noise, smooth the edges and recolour a scanned
signature. Installs with pip, ships a signature-enhancer
command, and is usable as a library. Built for personal projects and serious
development work alike.
⭐ View on GitHub · By Diganta Dey
Repository: https://github.com/DigantaDey/signature-improver Author: Diganta Dey License: Apache License 2.0
Why this tool
Signature cleanup is fiddly: uneven lighting, stray speckles, jagged edges and
inconsistent ink all break naive approaches. signature-improver uses a
vectorised OpenCV/NumPy pipeline that handles these cases reliably, then exposes
the result through both a zero-config CLI and a clean Python API.
Features
- Robust binarisation — Otsu, adaptive (local) and manual thresholding, with automatic polarity detection for dark-on-light and light-on-dark strokes.
- Noise removal — connected-component despeckling plus optional morphological opening/closing to drop speckles and fill gaps.
- Smooth edges — a Gaussian-blurred alpha channel produces anti-aliased strokes instead of jagged pixels.
- Luminance-preserving colour — strokes are tinted while keeping the original
shading and pen pressure; a
cleanmode paints solid ink for documents. - Flexible output — composite over the original background, white, or a transparent RGBA PNG; optionally crop to the signature bounding box.
- CLI + library — use
signature-enhanceron the command line or callenhance_signaturedirectly from Python. Batch and glob support built in.
Install
Install with pip straight from the GitHub repository — no PyPI account or
publishing required.
Option 1 — from GitHub (recommended)
pip install "git+https://github.com/DigantaDey/signature-improver.git"
Option 2 — from a local clone
git clone https://github.com/DigantaDey/signature-improver.git
cd signature-improver
pip install .
Option 3 — isolated CLI with pipx (personal use)
pipx install "git+https://github.com/DigantaDey/signature-improver.git"
Option 4 — editable install for development
git clone https://github.com/DigantaDey/signature-improver.git
cd signature-improver
pip install -e ".[dev]"
After installing, the signature-enhancer command is on your PATH. You can also
run it without installing globally:
python -m signature_enhancer --help
Quick start
# Blue, smoothed signature on a white background
signature-enhancer photo.jpg -o blue.png
# Transparent PNG, cropped to the signature, solid dark ink
signature-enhancer scan.png -o clean.png --background transparent --crop \
--mode clean --color "#000000"
# Batch process a folder of scans
signature-enhancer scans/*.jpg --output-dir out --mode clean
# Tune binarisation and denoise settings
signature-enhancer sig.png -o out.png --threshold adaptive --min-area 32 --smooth 5
Options
| Option | Choices / default | Description |
|---|---|---|
inputs |
files / globs | One or more images to process. |
-o, --output |
Output file (single input only). | |
--output-dir |
Write all results into this directory. | |
--mode |
colorize (default), clean |
colorize tints preserving luminance; clean paints solid strokes. |
--color |
#RRGGBB / name, default #1050ff |
Target stroke colour. |
--background |
keep (default), white, transparent |
Background handling. transparent writes RGBA PNG. |
--threshold |
otsu (default), adaptive, manual |
Binarisation strategy. |
--threshold-value |
127 |
Grey level for manual. |
--polarity |
auto (default), dark, light |
Dark-on-light vs light-on-dark. |
--min-area |
16 |
Drop components smaller than this (despeckle). |
--smooth |
3 |
Gaussian blur kernel for edge smoothing (odd, ≥1). |
--open / --close |
0 |
Morphological opening/closing kernel sizes. |
--crop |
Trim output to the signature's bounding box. | |
-q, --quiet |
Only report errors. |
How it works
- Binarise — the grey image becomes a stroke mask using Otsu (robust to uneven lighting), adaptive (local), or a manual threshold. Polarity is auto-detected so dark-on-light and light-on-dark signatures both work.
- Despeckle — connected components smaller than
--min-areaare removed. - Clean — optional morphological opening (thin noise) / closing (gaps).
- Smooth — a Gaussian blur on the mask produces a soft alpha channel, so edges are anti-aliased instead of jagged.
- Recolour — strokes are tinted with
--color. Incolorizemode the target colour is scaled by the original luminance, preserving pen pressure and anti-aliasing. Incleanmode strokes are solid. - Composite over the original, white, or a transparent alpha channel, then optionally crop to the bounding box.
Use as a library
from signature_enhancer import EnhanceOptions, enhance_signature
result = enhance_signature(
"photo.jpg",
"blue.png",
EnhanceOptions(
mode="colorize",
color=(255, 0, 0), # BGR blue
background="white",
crop=True,
),
)
print(f"Wrote {result.output_path} ({result.stroke_pixels} stroke pixels)")
Development
pip install -e ".[dev]"
pytest
The test suite covers the core algorithm (all threshold modes, every background, polarity, cleanup, crop, error handling) and the full CLI surface.
License
Licensed under the Apache License 2.0.
Metadata
Release files for signature-improver 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| signature_improver-1.0.0.tar.gz | 18.7 kB | Without provenance | Details for signature_improver-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| signature_improver-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for signature_improver-1.0.0-py3-none-any.whl |
Total release size: 34.3 kB
Release files / signature_improver-1.0.0.tar.gz
| Download URL | signature_improver-1.0.0.tar.gz |
|---|---|
| Size | 18.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1e89fe3e77f72b959b5ecf4a2a581422e917993b05f00f2f902edef8fda0954
|
|
BLAKE2b-256 checksum How to use checksums |
901f65264ccaf9830b59e5e88fca4c3acedbd9f8f3d8c422597f5226b26b9894
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Release files / signature_improver-1.0.0-py3-none-any.whl
| Download URL | signature_improver-1.0.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df8c3a42801a5200ba33923c3c0ffac081ebd86798583b60163548649f7e93e8
|
|
BLAKE2b-256 checksum How to use checksums |
467387af3d61398d1ee99d82f5df76869beb3efadaca9b7839591fa5ef30e6c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Security for signature-improver 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.