Add README.md

This commit is contained in:
RunasSudo 2025-05-08 21:43:32 +10:00
parent 7ae4b0f558
commit 730cf23ba7
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

24
README.md Normal file
View File

@ -0,0 +1,24 @@
# pdf-segmented
Generate PDFs using separate compression for foreground and background
## Usage
```
python -m pdf_segmented input.xcf output.pdf
```
Takes as input a [GIMP](https://www.gimp.org/) XCF file with one layer per page (bottom layer = first page).
All black pixels (#000000) will be considered to be foreground, and all remaining pixels will be considered to be background. This is most easily accomplished by selecting all colour graphics in GIMP, inverting the selection (Ctrl+I), then applying the [Threshold tool](https://docs.gimp.org/3.0/en/gimp-tool-threshold.html).
The foreground will be compressed losslessly using [JBIG2](https://en.wikipedia.org/wiki/JBIG2). The background will be compressed lossily using [JPEG](https://en.wikipedia.org/wiki/JPEG). JPEG quality can be controlled using the `--jpeg-quality` option; the default is the Pillow default (75% at time of writing).
Dependencies:
* [Python 3](https://www.python.org/) (tested using 3.13.3)
* [NumPy](https://numpy.org/) (tested using 2.2.5)
* [Pillow](https://pillow.readthedocs.io/en/stable/) (tested using 11.2.1)
* [pikepdf](https://pikepdf.readthedocs.io/en/latest/) (tested using 9.7.0)
* [ImageMagick](https://imagemagick.org/) (tested using 7.1.1.47)
* [jbig2enc](https://github.com/agl/jbig2enc) (tested using 0.30)