This is just an informal write-up of my private/spare-time fiddling with pdfeTeX (it's for fun).
When a PNG image is read in by pdfTeX, it is first decompressed into an RGB pixel array, and then losslessly recompressed using zlib. The small size of an original PNG image comes from the use of predictors, which filter the image before compressing. This PNG predictor information is also used by pdftex during decompressing of the image into the RGB array. However the following compressing step by zlib into the PDF image stream does not use prediction. As a result, the images embedded by pdftex are often of larger size than the original PNG images. Further, decompressing and recompressing are slow processes.
There are many cases, where PNG image streams can be embedded natively into the PDF output without the decompressing and recompressing steps. This normally results in a higher processing speed and smaller PDF file size.
In this experimental patch, for which I got the idea from Thomas Merz' fine pdflib, the PNG file to be embedded is checked for its type, and if native embedding is possible, it is done; else the image is decompressed and compressed as usual.
This patch has been tested with Willem van Schaik's PNG test suite (PngSuite.tar.gz). It seems, that pdftex can correctly embed the 155 valid PNG files, from which about 73 files are natively copied by the code of this patch.
A snapshot of the patched file writepng.c (the original is from pdfeTeX, version (Web2C 7.5.3) 3.141592-1.20a-rc4-2.1) can be downloaded.
Experimental patch, not for production, may be buggy. No warranty whatsoever.
This page first put online 16 June 2004.
Last file change: 2004/07/17