Redwings PDF Tools: desktop PDF compressor and toolkit
Visa documents must fit strict upload limits. This desktop tool compresses PDFs with several modes and uses a binary search to find the sharpest output under a target size.
- Period
- Jul 2026
- My role
- Solo: engine, GUI and packaging
- Technologies
- 4
- Diagrams
- 1
- Reading time
- 1 min
Summary
The engine analyses each PDF (text vs scanned, bitonal suitability, DPI) and chooses or applies a compression strategy:
- Tier A lossless (pikepdf optimise)
- Tier B image downsample / re-encode (PyMuPDF, optional Ghostscript)
- Tier C bitonal 1-bit (CCITT / PNG) for text scans
- MRC two-layer mixed raster content (ABBYY-style)
Modes are precision (Adobe-like, text-safe), balanced (Wondershare-like), maximum (ABBYY-like) and auto. Strength is level 1–5, a quality override, or a target size, which triggers a binary search for the sharpest result under the limit. Groups escalate compression across files until the bundle fits. Every version is kept with an “under target” badge. Results, recent files, sessions and templates are stored in SQLite. The UI was built first in Tkinter (themed, light / dark) and then ported to PySide6 (Qt) with background workers, a cancel / stop button and timers.
Stack
PyMuPDF 1.28, pikepdf 10.10, pypdf 6.14, Pillow 12.3, PySide6 6.11, Tkinter / ttk (legacy UI), SQLite (db.py), optional Ghostscript (gswin64c), PyInstaller (RedwingsPDFTools.spec, build_exe.cmd, app icon), pyright config, headless engine smoke test.
Architecture
app/
├─ config.py (colours, fonts, paths, MODE / LEVEL tables) · theme.py · utils.py · models.py (CompressionSettings, DocFile, Group, Template) · db.py · logging_setup.py · templates_def.py
├─ engine/ detect (capabilities) · analyze (text / scan / DPI, auto mode) · pdf_ops (shuffle / merge / split / rotate / reorder)
│ tier_lossless · tier_image · tier_bitonal · tier_mrc · render · compress (orchestrator + target search) · pipeline (group escalation) · cancel
├─ qt/ main_window, compressor_page (794), template_page (689), tools_pages, settings_page, preview_dialog, template_editor_dialog, widgets, flowlayout, workers (QThread), theme, dialogs
└─ ui/ (Tkinter) app, compressor_view, template_view, preview, merge / shuffle / split views, filelist, widgets
Diagram as text
flowchart LR
F[PDFs / group] --> AN[analyze: text vs scan, DPI, bitonal]
AN --> MODE{mode}
MODE --> TA[Tier A lossless]
MODE --> TB[Tier B image re-encode / Ghostscript]
MODE --> TC[Tier C bitonal]
MODE --> MRC[MRC two-layer]
TA & TB & TC & MRC --> SEARCH[target-size binary search on quality]
SEARCH --> OUT[versions + under-target badge → Documents/redwings-pdftools]
OUT --> DB[(SQLite results / sessions)]Algorithm: target-size search
lo, hi = quality bounds; best = None; while lo ≤ hi: q = mid; out = compress(q); if size(out) ≤ target: best = out; lo = q + 1 else hi = q − 1 → if no result fits, escalate the tier (image → bitonal → MRC) and, for groups, compress the largest contributors further.
Resume Bullet
Built a PySide6 desktop PDF toolkit with an adaptive multi-tier compression engine (lossless, image, bitonal, MRC) and target-size binary search, packaged with PyInstaller for a visa agency.
Related projects
PDF Agent: PDF split and shuffle tool (4 versions)
A small Tkinter desktop tool that splits PDFs several ways for visa-document preparation, refined through four versions in one week.
PythonPDF & document generationDesktop GUI (Tk / Qt)Bulk test-document generator and Stitch-to-PDF storyboard
Python scripts that batch-generate numbered test documents (Word to PDF, Pillow images) plus a Stitch-to-PDF storyboard for QA and design review.
PythonPDF & document generationcopyCode prototypes: 15 versions towards ThuOneCopy
Fifteen PyQt5 prototype versions of a tool that copies selected project files as one block for ChatGPT, evolving into ThuOneCopy.
PythonDesktop GUI (Tk / Qt)Want to discuss this project?
Happy to walk through the architecture, trade-offs or the code.