I often use a command like this:

$ pdfjam --a4paper -o "$pdf" "$png"

The input png file is 105kb and the resulting pdf is 97kb. The beauty and strength of pdfjam is that it uses pdfpages to simply insert images as they are without manipulation (whereas most other tools such as ImageMagick insist on transcoding images).

So what explains the fact that the output is smaller? If some kind of non-lossy compression is used within the PDF container, the PNG should not be that significantly compressable, I would think. Otherwise that would imply a notable inefficiency in the png algorithm.

  • Chaf
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 days ago

    Very interesting, thanks for the write-up!

    Just as an aside, but you also noted it yourself

    I thought PNG was inherently lossless but the pngquant tool proves there is a lossy compression algo.

    PNG itself is lossless, it’s just that pngquant “manipulates” the image to be better compressible.

    And I didn’t know about DjVu at all, that’s really good to know!