|Summary:||FOP crashing with exception when embedding PNG|
|Product:||XMLGraphicsCommons - Now in Jira||Reporter:||Oliver Kiddle <okiddle>|
|Component:||image codecs||Assignee:||XML Graphics Project Mailing List <general>|
Description Oliver Kiddle 2008-09-12 03:41:55 UTC
I'm including a PNG file in a document and FOP is crashing with the following exception. This previously worked in fop 0.94. Note that there's a typo in the error message and that could also be fixed. java.lang.IllegalStateException: The resolution mus be set at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:217) at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:125) at org.apache.fop.cli.Main.startFOP(Main.java:166) at org.apache.fop.cli.Main.main(Main.java:197) --------- java.lang.IllegalStateException: The resolution mus be set at org.apache.xmlgraphics.image.loader.ImageSize.calcSizeFromPixels(ImageSize.java:210) The PNG file in question was created using Dia. pngcheck for the image shows: OK: a.png (567x400, 24-bit RGB, non-interlaced, 96.0%) pngmeta showed nothing. My guess is that there is no information in the image to indicate DPI. Surely, in this situation, it should just be guessing. The XSL-FO used is as follows: <fo:external-graphic src="url(a.png)" width="432pt" height="auto" content-width="scale-to-fit" content-height="scale-to-fit" content-type="content-type:image/png" text-align="center"/> Given that it is scaling, I would have thought that the resolution should be irrelevant. The XSL-FO file came from Docbook-xsl but I can reproduce it by copying the file into a hello world XSL-FO file. I'd prefer not to post the image file publicly but if anyone needs it, I can e-mail it privately. Oliver Kiddle
Comment 1 Jeremias Maerki 2008-09-19 00:45:11 UTC
Oliver sent me a test file off-list. The PNG contains a pHYs chunk but the resolution is set to 0. This PNG is certainly bad but it is possible to make XML Graphics Commons's image loader framework more robust so it doesn't throw an exception in such a case. Will commit a fix shortly.