I graduated with a degree in Printing and Packaging Technology and spent the last few years doing freelance graphic design branding, packaging, visual identity work. A few weeks ago, I started learning Python from scratch.
Somewhere around the "variables and f-strings" stage of my learning, I had an idea: every print/packaging designer I know does the same tedious math by hand, over and over — converting units, calculating bleed, translating CMYK to RGB for screen previews. There wasn't a clean Python library for any of it.
So I decided to build one — and publish it to PyPI as a way to actually use what I was learning instead of just doing tutorial exercises.
The result is pkgprint — a small, zero-dependency library for print and packaging math.
What it does
bash
pip install pkgprint
python import pkgprint
Standard paper sizes, no more googling "A4 size in mm"
w, h = pkgprint.paper_size("A4")
print(w, h)
→ 210 297
Add bleed to a business card before sending to print
bleed_w, bleed_h = pkgprint.add_bleed(89, 51, bleed_mm=3)
print(bleed_w, bleed_h)
→ 95 57
Convert a brand color from CMYK to RGB for a screen mockup
rgb = pkgprint.cmyk_to_rgb(0, 100, 100, 0)
print(rgb)
→ (255, 0, 0)
Or straight to hex
print(pkgprint.rgb_to_hex(*rgb))
→ #FF0000
It covers four areas:
Unit conversions — mm ↔ inches ↔ points, DPI/PPI
Color conversions — CMYK ↔ RGB, hex ↔ RGB
Standard sizes — ISO paper sizes, US sizes, common packaging box dimensions
Print production math — bleed, safe margins, trim size calculations
What I learned building it
This was my first time going through the entire pipeline of shipping software, not just writing code that runs once:
Modules and packages — how a folder of .py files with an init.py becomes one importable unit
Testing — I wrote 100+ tests with pytest, including round-trip tests (e.g. converting RGB → CMYK → RGB and checking I get back roughly what I started with) — these caught real edge cases I hadn't thought about, like pure black in CMYK causing a division-by-zero in my first draft of the RGB-to-CMYK formula
Packaging — pyproject.toml, building with python -m build, and the difference between a source distribution and a wheel
The publish pipeline — TestPyPI first (to catch mistakes safely), then the real PyPI
The most surprising part: writing the tests actually forced me to think harder about the domain logic than writing the functions did. A test like "business card size + 3mm bleed on each side should equal exactly this" makes you notice ambiguity you didn't know was there — like the fact that "business card" means a different physical size in the US vs. ISO/European standards. That's a bug I only caught because a test forced me to be specific.
Try it / feedback welcome
PyPI: https://pypi.org/project/pkgprint/
Source: https://github.com/Rishabh55122/pkgprint
It's early (0.1.0), so if you work with print, packaging, or design-adjacent tooling and see something missing or wrong, I'd genuinely appreciate an issue or PR. And if you're also learning Python and thinking about building something — my honest takeaway is: pick a problem you already understand deeply from a non-coding background. It made the "why" of testing and structuring code obvious in a way tutorials hadn't.
Top comments (0)