xmlgraphics-fop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johannes (Jira)" <j...@apache.org>
Subject [jira] [Commented] (FOP-3022) Embedded PNG and PNG with relative path: No ImagePreloader found
Date Thu, 22 Jul 2021 11:40:00 GMT

    [ https://issues.apache.org/jira/browse/FOP-3022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17385431#comment-17385431
] 

Johannes commented on FOP-3022:
-------------------------------

After further analysis it turned out that
 * above error was caused by the invalid data image. When using a valid data image the standalone
PDF generation worked well (whereas it did not in the application).
 * the error in the application was caused by wrong selection of the base URL: The base URL
was set to the config file. Setting it to the directory of the config file, the generation
works. (Yet there is a change in behaviour: In FOP 2.3 this configuration worked well.)

Nevertheless FOUserAgent.resolveURI should be reviewed: Setting the systemId so to something
else than the submitted uri appears odd. Patching this resolved the issue as well.

> 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
>            Priority: Major
>
> 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)

Mime
View raw message