视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
pdf-look-scanned【文档与办公】Make PDF documents look like they were scanned on a physical scanner. Applies realistic effects: grayscale conversion, Gaussian noise, slight rotation, blur, edge shadows, and random offset. Optionally extract real handwritten signatures from a source PDF (or user-provided images) and replace digital signatures on specific pages. Use when the user as…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Make PDFs look like physical scans with optional signature replacement.
pip3 install pillow pdf2image img2pdf numpy
Also requires poppler (provides pdftoppm):
brew install popplerapt install poppler-utilsdnf install poppler-utilspacman -S popplerconda install -c conda-forge poppler or download from poppler releasesRun scripts/make_scanned.py for the core functionality. Read the script's --help for all options.
python3 scripts/make_scanned.py document.pdf
Lower DPI and quality = grittier, more realistic cheap-scanner look:
python3 scripts/make_scanned.py document.pdf --dpi 150 --quality 75 --noise 7
Higher DPI = cleaner scan, larger file:
python3 scripts/make_scanned.py document.pdf --dpi 300 --quality 92
Before replacing signatures, determine crop and placement coordinates. All coordinates are fractions of page dimensions (0.0-1.0).
Use this Python snippet to explore coordinates interactively:
from pdf2image import convert_from_path
from PIL import Image
pages = convert_from_path("document.pdf", dpi=200)
page = pages[0] # 0-indexed
w, h = page.size
# Crop a region and save for inspection
crop = page.crop((int(w*0.5), int(h*0.4), int(w*0.8), int(h*0.6)))
import tempfile, os
crop.save(os.path.join(tempfile.gettempdir(), "crop_test.png"))
python3 scripts/make_scanned.py contract.pdf \
--sig-pdf signatures.pdf \
--sig-page 1 --sig-crop 0.41,0.33,0.62,0.42 \
--sig-target 25 --sig-clear 0.61,0.41,0.85,0.52 --sig-place 0.62,0.415
Each set of --sig-page, --sig-crop, --sig-target, --sig-clear, --sig-place adds one replacement. They are matched positionally:
python3 scripts/make_scanned.py contract.pdf \
--sig-pdf signatures.pdf \
--sig-page 1 --sig-crop 0.41,0.33,0.62,0.42 \
--sig-target 25 --sig-clear 0.61,0.41,0.85,0.52 --sig-place 0.62,0.415 \
--sig-page 2 --sig-crop 0.40,0.335,0.62,0.39 \
--sig-target 27 --sig-clear 0.61,0.635,0.85,0.72 --sig-place 0.60,0.655
| Parameter | Description |
|---|---|
--sig-pdf | Source PDF containing real signatures |
--sig-page N | Page number in source PDF (1-indexed) |
--sig-crop L,T,R,B | Crop box to extract signature (fractions) |
--sig-target N | Target page to replace signature on (1-indexed) |
--sig-clear L,T,R,B | Area to white-out old signature (fractions) |
--sig-place X,Y | Top-left position to paste new signature (fractions) |
--sig-size F | Signature width as fraction of page width (default: 0.11) |
--sig-dpi N | DPI for rendering source signature PDF (default: 350) |
| Parameter | Default | Effect |
|---|---|---|
--dpi | 200 | Render resolution. Lower = grittier |
--quality | 85 | JPEG compression. Lower = more artifacts |
--noise | 5.0 | Gaussian noise stddev. Higher = noisier |
--blur | 0.6 | Gaussian blur radius. Higher = softer |
--rotation | 0.7 | Max rotation in degrees |
--contrast-min | 0.88 | Min contrast (lower = more washed out) |
--contrast-max | 0.95 | Max contrast |
When the user provides a PDF and a separate signature source:
pillow, pdf2image, img2pdf, numpy, poppler)exiftool on the output to ensure no software traces remainCommon pitfalls:
--sig-size (0.11 is typical for contracts)--sig-dpi (350+) and higher ink threshold