Faster PDF Compression With Smaller Files

P
Paulius
ConvertAPI

PDF to Compress has a new image compression engine. On our benchmark documents it was 3.6 times faster in total, and most files came out smaller or about the same size.

Highlights

  • No more files that grow. Images that need no downsampling are left as they are, unless re-encoding makes them clearly smaller. Before, the Printer preset could return a file bigger than the one you sent.
  • Accurate image resolution. Resolution is measured from the image's real size on the page, not from its file metadata. An image used several times is sized by its largest use, so no copy turns blurry.
  • Readable scans. Black-and-white scans are never downsampled, so their text stays sharp.
  • Smarter JPEG handling. A JPEG is never re-encoded at a higher quality than it was saved with. When it is unclear whether JPEG helps, the image is test-encoded first and replaced only when it gets at least 10% smaller.
  • Lossless photos become JPEG when that makes them clearly smaller.
  • Small details survive. Images are never shrunk below 16 pixels on the short side, so icons and thin lines do not vanish.
  • Parallel processing. Documents with many large images use several CPU cores at once, with the same result as processing them one by one.
  • Fewer failures. A document that cannot be linearized is returned without linearization instead of failing.

We compared the previous engine with the new one on six test documents, using the median of three runs:

Document Preset Original Before Now Speed-up
Restaurant menu, 2 pages Text 5.3 MB 318 KB 240 KB 1.5x
Restaurant menu, 2 pages Web 5.3 MB 1.7 MB 862 KB 1.5x
Restaurant menu, 2 pages Printer 5.3 MB 5.3 MB 4.0 MB 1.0x
Mixed image types, 6 pages Text 15.1 MB 319 KB 53 KB 1.0x
Mixed image types, 6 pages Web 15.1 MB 911 KB 337 KB 1.0x
Mixed image types, 6 pages Printer 15.1 MB 5.4 MB 5.2 MB 0.8x
Large document with low-resolution images Text 24.6 MB 1.3 MB 1.5 MB 8.1x
Large document with low-resolution images Web 24.6 MB 24.6 MB 24.6 MB 81x
Large document with low-resolution images Printer 24.6 MB 24.6 MB 24.6 MB 216x
Web article with images, 10 pages Text 957 KB 80 KB 83 KB 1.5x
Web article with images, 10 pages Web 957 KB 240 KB 276 KB 1.3x
Web article with images, 10 pages Printer 957 KB 609 KB 613 KB 2.2x
JPEG 2000 images with transparency, 24 pages Text 18.7 MB 578 KB 587 KB 2.3x
JPEG 2000 images with transparency, 24 pages Web 18.7 MB 3.1 MB 2.7 MB 2.6x
JPEG 2000 images with transparency, 24 pages Printer 18.7 MB 9.2 MB 8.9 MB 9.0x
Grayscale scan, 50 pages Text 14.0 MB 191 KB 160 KB 3.8x
Grayscale scan, 50 pages Web 14.0 MB 4.0 MB 4.2 MB 5.2x
Grayscale scan, 50 pages Printer 14.0 MB 14.0 MB 14.0 MB 32x

Documents that cannot get smaller now come back almost at once, instead of going through a full re-encoding. The new engine made a noticeably larger file in two cases. With the Text preset, the large document came out 10% bigger, because the previous engine resampled more softly. With the Web preset, the web article came out 15% bigger, because one of its images is only 4% above the target resolution and is now left untouched.

Try it out

Learn more