From 730cf23ba701da05ec18e21fb0e429e4a906c504 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Thu, 8 May 2025 21:43:32 +1000 Subject: [PATCH] Add README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..10400e7 --- /dev/null +++ b/README.md @@ -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)