2025-05-08 23:15:05 +10:00
2025-05-08 19:27:05 +10:00
2025-05-08 19:27:05 +10:00
2025-05-08 21:43:32 +10:00

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 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).

Dependencies:

Description
Generate PDFs (or DjVu) using separate compression for foreground and background
https://yingtongli.me/blog/2025/05/09/pdf-segmented.html
Readme 0 B
Languages
Python 100%