Johannes created FOP-3022:
-----------------------------

             Summary: Embedded PNG and PNG with relative path: No 
ImagePreloader found
                 Key: FOP-3022
                 URL: https://issues.apache.org/jira/browse/FOP-3022
             Project: FOP
          Issue Type: Bug
          Components: image/png
    Affects Versions: 2.6
            Reporter: Johannes


A PDF with an embedded PNG and another PNG with a relative URL does not contain 
either of these images (as it worked before in FOP version 2.3).

This is the error reported in the debug trace:

Image not available. URI: 
data:image/png;base64,0000C3E449BA11000000000000000000F33319879C248B7149B918E031DA9E37336F93FA7DE2500F377C435E31F7DCE86730D41D33A8.
 Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is 
not supported. No ImagePreloader found for 
data:image/png;base64,0000C3E449BA11000000000000000000F33319879C248B7149B918E031DA9E37336F93FA7DE2500F377C435E31F7DCE86730D41D33A8
 (No context info available)
org.apache.xmlgraphics.image.loader.ImageException: The file format is not 
supported. No ImagePreloader found for 
data:image/png;base64,0000C3E449BA11000000000000000000F33319879C248B7149B918E031DA9E37336F93FA7DE2500F377C435E31F7DCE86730D41D33A8

Result of debugging (using FOP 2.6 sources):
 * FOUserAgent.resolveURI creates a StreamSource from the PNG. The resource URI 
is correctly resolved (i.e. the StreamSource has an InputStream on the PNG) but 
the method sets an invalid systemId (the base URI of the resource resolver, 
which points to the config file, cfg.xml in our case)
 * AbstractImageSessionContext.newSource (from xmlgraphics-commons-2.6; 
instantiated in the FOUserAgent constructor) uses the fallbackResolver for any 
StreamSource.
 * AbstractImageSessionContext.UnrestrictedFallbackResolver.createSource 
quietly closes the InputStream of the StreamSource and requests the systemId 
from ImageIO instead (code comment: "We let the OS' file system cache do the 
caching for us --> lower Java memory consumption, probably no speed loss")
Thus it opens a stream on the cfg.xml instead of the image
 * Consequentually, PreloaderRawPNG doesn't feel responsible for the wrong PNG 
because it doesn't start with the PNG signature (PNGConstants.PNG_SIGNATURE) - 
which is caused by reading a completely different file than the PNG

Same behaviour also for another PNG included with a simple relative file URL 
(<fo:external-graphic src="url('subdir/myimage.png')" /> hardcoded in the XSL).

The issue is reproducible as well when running the generation standalone from 
the command line (using -xml, -xsl and -pdf options).

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to