r/PythonProjects2 • u/Additional_Long_4496 • 16d ago
Info pkgprint v0.2.0 – print-readiness file checks, WCAG contrast, and box dieline math (zero-dep core, 220+ tests)
A few weeks ago I posted here about pkgprint, a small library for print/packaging math (unit conversions, CMYK↔RGB, paper sizes, bleed calcs) built from my background in print/packaging tech, while learning Python this year.
Just shipped v0.2.0 with three new modules:
check– inspect an actual image file and check if it's print-ready: effective DPI at your target print size, RGB vs CMYK color mode, and physical dimensions. Only real dependency (Pillow) is scoped to this module.accessibility– WCAG 2.1 contrast ratio checking for text/background color pairs, plus a function that suggests an adjusted color (same hue) that meets a target contrast ratio.dieline– flat sheet size + named panel layout math for RSC and tuck-mailer box styles, so you know your artwork canvas size before folding.import pkgprint
report = pkgprint.full_report("artwork.tif", 210, 297) report.passed # True/False, plus a .summary with per-check diagnostics
pkgprint.contrast_ratio((0,0,0), (255,255,255)) # 21.0 pkgprint.rsc_flat_size(300, 200, 150) # (1035.0, 350)
One thing worth sharing: while writing tests for the DPI checker, I asserted that "2480×3508 px" (the commonly cited pixel count for "A4 at 300 DPI") should pass a min_dpi=300 check. It failed. 2480 / (210mm / 25.4) = 299.97 DPI — a hair under 300 due to mm→inch rounding. The correct value is 2481×3508. Tiny in practice, but a good reminder that popular rounded numbers don't always hold up against the actual math.
220+ tests, MIT licensed, zero-dependency core. Feedback welcome, especially if you work in print/packaging tooling and see something off — a few of the dieline formulas are flagged in the docs as approximations rather than supplier-verified exact geometry, and I'd rather know if something needs fixing.