XMLGraphicsCommons includes an image loader for raw PNG. This means the PNG bytes from the IDAT chunk can be embedded in the output format (PDF and PS for now) without the need to decode them. Note that usually the decoding would revert the filter applied to the image bytes (this is a filter applied before compression to make the PNG files smaller) resulting in larger files and sometimes a performance impact (reverting some filters, in particular the Paeth filter, is generally expensive).
The ImageLoaderRawPNG is not selected (it has an intrinsic penalty of 1000) by default since it does not handle all kinds of PNG images. As of this writing it only supports images with 8 bits per channel (which are most of the PNG images), without interlacing. To enable the image loader a negative penalty needs to be awarded to it in the FOP configuration file (fop.xconf):
<image-loading> <penalty value="-10000" class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderRawPNG" /> <penalty value="INFINITE" class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderPNG" /> </image-loading> <renderers> <renderer mime="application/pdf"> <filterList> <value>flate</value> </filterList> <xmlHandler mime="text/svg+xml"/> </renderer> <renderer mime="application/postscript"> <xmlHandler mime="text/svg+xml"/> </renderer> </renderers>
Note that in the above example the ImageLoaderPNG image loader has been disabled. The penalty of -10000 (reverse penalty) compensates the default penalty of 1000, and makes the ImageLoaderRawPNG image loader the preferred one (the default image loader, org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderImageIO, has no intrinsic penalty).
The ImageLoaderPNG image loader is similar to the ImageLoaderImageIO one, in the sense that it also decodes the IDAT chunk, but it does so using the org.apache.xmlgraphics.image.codec.png.PNGImageDecoder class instead of com.sun.imageio.plugins.png.PNGImageReader class. In practical terms, it offers no advantages over the default ImageLoaderImageIO, except in situations where a JVM does not offer a PNG image reader.