1.5 KiB
pdf-segmented
Generate PDFs (or DJVU) using separate compression for foreground and background
Usage
python -m pdf_segmented input.xcf output.pdf
Takes as input a GIMP 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.
The foreground will be compressed losslessly using JBIG2. The background will be compressed lossily using JPEG. JPEG quality can be controlled using the --jpeg-quality
option; the default is the Pillow default (75% at time of writing).
Additional compression algorithms are supported (JPEG 2000, PNG); see --help
for detailed options. DJVU output (foreground JB2, background IW44) is also supported.