PDF compression produces very little size reduction
Hi! I'm testing the PDF compression feature in PDFCraft and I'm trying to understand how the different compression levels are expected to work.
I tested the Low compression option on a PDF containing a significant amount of content/images, but the resulting file was only about 1 MB smaller than the original.
For example:
Original PDF: XX MB
Low compression: XX MB
Reduction: ~1 MBI investigated the Docker image and found that workers/compress.worker.js uses coherentpdf:
coherentpdf.compress(pdf);
coherentpdf.squeezeInMemory(pdf);For low, it then generates and compresses object streams:
coherentpdf.toMemoryExt(
pdf,
false,
false,
false,
true,
true
);From what I can see, this appears to optimize PDF streams and structure, but it does not seem to perform image downsampling or JPEG recompression.
I also noticed that the project includes PyMuPDF WASM, Pillow, OpenCV, and QPDF WASM, so I was wondering whether there is another image-compression step elsewhere in the application.
Questions
- Is the current
Lowcompression level expected to only perform structural/stream compression? - Does PDFCraft currently perform any image downsampling or JPEG/PNG recompression when using
Low,Medium, orHigh? - If not, is image recompression planned for the compression feature?
- What is the intended difference in compression behavior between
Low,Medium, andHigh? - Is there a recommended way to achieve significantly smaller PDFs, especially for PDFs containing scanned pages or high-resolution images?
For example, I would expect something along these lines for image-heavy PDFs:
Low: aggressive image compression / downsampling
Medium: balanced compression
High: higher quality with moderate compression
Maximum: preserve original image qualityI'm asking because a PDF that is, for example, 30–50 MB may only become approximately 1 MB smaller with Low, which seems much less than what I would expect from a PDF compression tool.
Thanks!
Source: PDFCraftTool/pdfcraft