Created attachment 27243 [details] Profiler Hello, Iām using fop 1.0 (xmlgraphics 1.4) to generate PDF, I noticed that PDF generation with PNG or TIF image is 7 times longer. The problem doesn't appear in the version 1.3 of xmlgraphics. The problem seems to come from color model associated with the image. * if is_sRGB_stdStale = true then getRBG method is very fast * if is_sRGB_stdStale = false then getRBG is slow because the treatment is delegated to ICC_ColorSpace.toRGB The color model is correct, but it is modified by the class org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderImageIO by the following code : if (providerIgnoresICC && cm instanceof ComponentColorModel) { // Apply ICC Profile to Image by creating a new image with a new color model. ICC_Profile iccProf = tryToExctractICCProfile(iiometa); if (iccProf != null) { ColorModel cm2 = new ComponentColorModel( new ICC_ColorSpace(iccProf), cm.hasAlpha(), cm .isAlphaPremultiplied(), cm .getTransparency(), cm.getTransferType()); WritableRaster wr = Raster.createWritableRaster(imageData .getSampleModel(), null); imageData.copyData(wr); BufferedImage bi = new BufferedImage(cm2, wr, cm2 .isAlphaPremultiplied(), null); imageData = bi; cm = cm2; I removed this code and it works fine now, but it's dirty. What's the impact ? Until a fix, best regards.
patch (from bug 51149) applied at: http://svn.apache.org/viewvc?rev=1345323&view=rev
Hi, We applied your patch but it dont fix my issue. What information do you need about the PNG Image ? Regards,
this bug is linked to bug 51149 but the issue may be different... the slowdown addressed by the patch appeared due to a change in the jdk, not from a change in xmlgraphics (from 1.3 to 1.4). please provide the image so that the issue can be investigated. does it happen with all images or just some?
Created attachment 28971 [details] PNG image
I attached the concerned PNG image. The image is used inside a PDF document generated by FOP. This image used by FOP 0.95+XmlGraphics 1.3.1 had no performance issue during the PDF generation. Changing JDK has no effect in my case.
Created attachment 29041 [details] an example to test icc profiles the slowdown that happens between xmlgraphics-1.3 and xmlgraphics-1.4 is due to the fact that the color profiles were being ignored in 1.3 while in 1.4 they are taken into account, as the PNG specification suggests. so even though 1.3 was faster, it was not correct. the impact of removing the check for color profile is that the output may be wrong, although in most cases that does not happen because the color pixel values in the PNG image already match what the embedded color profile expects. attached is an example with two images that look the same when viewed in an application that does not apply color profiles (like Chrome), but that look different when viewed with an application that applies the color profile (like Safari). the example, when processed with FOP-0.95 (xmlgraphics-1.3) generates two images that look the same, while with FOP-1.0 (xmlgraphics-1.4) the images look different. a workaround, as was suggested somewhere else, is to remove the color profile from the image (this can be done with imagemagick). obviously this only works in the cases where the color profile is not adding anything new to the image. another option is to use the new raw png image loader, which for now, still ignores the color profile (of course, this will not help in the cases where the color profile is important).
as a follow-up to previous comment 6, see bug 40676, with attachment 29132 [details] (a patch that adds support for color profiles)