inv-pdf
Invert PDF colors (dark-mode) for a file or entire directory — with parallel processing across CPU cores.
The Problem
Reading white-background PDFs at night or on OLED screens is painful. inv-pdf inverts every page of a PDF to produce a dark-mode version, with near-black pixels clamped to pure black to avoid muddy greys.
Installation
pip install inv-pdf
Dependencies: pymupdf and Pillow are installed automatically.
Usage
CLI
# Invert all PDFs in current directory (creates file_inverted.pdf for each)
inv-pdf .
# Specify output directory
inv-pdf ./pdfs -o ./dark-pdfs
# Custom DPI, suffix, and parallelism
inv-pdf ./pdfs --dpi 150 --suffix _dark --jobs 4
# Full help
inv-pdf --help
Python API
from inv_pdf import invert_pdf
# Invert a single PDF
invert_pdf("document.pdf", "document_inverted.pdf", dpi=300)
Options
| Flag | Default | Description |
|---|---|---|
DIR |
. |
Directory of PDFs to process |
-o / --output |
Same as input | Output directory |
-s / --suffix |
_inverted |
Suffix added to output filenames |
-d / --dpi |
300 |
Render resolution (higher = better quality, slower) |
-j / --jobs |
CPU count | Number of parallel worker processes |
--ext |
.pdf |
File extension to match |
How It Works
- Opens each PDF with PyMuPDF (
pymupdf) - Rasterises each page at the specified DPI
- Inverts pixel values:
255 − xfor each RGB channel via Pillow - Clamps near-black pixels (all channels < 100) to pure
(0, 0, 0) - Re-encodes each page as PNG and embeds it back into a new PDF
- Preserves the original TOC and metadata
- Saves with
deflate=True, garbage=4, clean=Truefor compact output
Requirements
- Python 3.8+
pymupdf >= 1.23.0Pillow >= 9.0.0
License
MIT © Santt997
Metadata
Release files for inv-pdf 0.1.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 | |
|---|---|---|---|---|
| inv_pdf-0.1.0.tar.gz | 7.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| inv_pdf-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / inv_pdf-0.1.0.tar.gz
| Download URL | inv_pdf-0.1.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d98481e02495d7616efcdba0e09ed9682c3e0b2650babd86196edefa50544ab2
|
|
BLAKE2b-256 checksum How to use checksums |
bf230b3139d8f0fa0b972c73ebcb2fcbd557b69a151ee98dcabf46f3832a46c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / inv_pdf-0.1.0-py3-none-any.whl
| Download URL | inv_pdf-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14c381f3c486ac31400087995cb5a00c7d0f9b4a5b8a840b86ffa880716e1a87
|
|
BLAKE2b-256 checksum How to use checksums |
f7154e272e9cb8ccb1429d14c31f4277fc099d104f55c12051165ecf0419a3b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for inv-pdf 0.1.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.