You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Roberto Cahanap <rc...@BioReference.com> on 2013/10/16 20:39:52 UTC

png vs. jpg

Hello everyone.

We have been trying to figure out why our pdf generation was taking so long.

When we changed an image in the PDF from PNG to JPG, then it was much faster.

Is there a difference in the way these two graphic formats are processed in FOP?

Thank you for your responses.

-Roberto

The information transmitted in this email and any of its attachments is intended only for the person or entity to which it is addressed and may contain BioReference Laboratories proprietary information, which is privileged, confidential, or subject to copyright belonging to BioReference Laboratories. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be unlawful. If you received this in error, please contact the sender immediately and delete and destroy the communication and all of the attachments you have received and all copies thereof.

Re: png vs. jpg

Posted by Luis Bernardo <lm...@gmail.com>.
That is a good question! It seems to be some legacy configuration that 
copied from an existing fop.xconf that apparently is not used anymore. 
But I will need to investigate because I do not have an answer.

On 10/17/13 10:49 AM, Bernard Giannetti wrote:
> Hi Luis,
>
> I went to the page you provided (ImageLoaderRawPNG) and noticed in the 
> config for application/pdf
>
> <xmlHandler mime="text/svg+xml"/>
>
> I searched for xmlhandler and cannot find any reference to this tag 
> (other than the page you gave).
>
> I'm generating PDFs using embedded FOP (which include a small SVG 
> image).  As a test, I generated a PDF with the tag in the FOP config 
> and then without and I noticed no (obvious) difference in 
> timing/memory.  Is this tag necessary...what does it do?
>
>
> Thanks in advance,
>
> Bernard.
>
>
> ------------------------------------------------------------------------
> Date: Wed, 16 Oct 2013 23:44:52 +0100
> From: lmpmbernardo@gmail.com
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: png vs. jpg
>
>
> <snip>
> Yes, there is a difference. By default FOP uses a "native" image 
> loader for JPG but not for PNG. There is however a native image loader 
> for PNG too, which you can enable in the configuration file. See 
> http://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG for 
> more info. Try it and I expect that you will see a performance 
> improvement.
> </snip>


RE: png vs. jpg

Posted by Bernard Giannetti <th...@hotmail.com>.
Hi Luis,
I went to the page you provided (ImageLoaderRawPNG) and noticed in the config for application/pdf
<xmlHandler mime="text/svg+xml"/>
I searched for xmlhandler and cannot find any reference to this tag (other than the page you gave).
I'm generating PDFs using embedded FOP (which include a small SVG image).  As a test, I generated a PDF with the tag in the FOP config and then without and I noticed no (obvious) difference in timing/memory.  Is this tag necessary...what does it do?

Thanks in advance,Bernard.

Date: Wed, 16 Oct 2013 23:44:52 +0100
From: lmpmbernardo@gmail.com
To: fop-users@xmlgraphics.apache.org
Subject: Re: png vs. jpg


  
    
  
  
    
<snip>

      Yes, there is a difference. By default FOP uses a "native" image
      loader for JPG but not for PNG. There is however a native image
      loader for PNG too, which you can enable in the configuration
      file. See
      http://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG for
      more info. Try it and I expect that you will see a performance
      improvement.
</snip> 		 	   		  

RE: png vs. jpg

Posted by Roberto Cahanap <rc...@BioReference.com>.
Ah, that makes sense then. I'm going to read the link that you referenced.

Thank you Luis.

-Roberto


From: Luis Bernardo [mailto:lmpmbernardo@gmail.com]
Sent: Wednesday, October 16, 2013 6:45 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: png vs. jpg


Yes, there is a difference. By default FOP uses a "native" image loader for JPG but not for PNG. There is however a native image loader for PNG too, which you can enable in the configuration file. See http://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG for more info. Try it and I expect that you will see a performance improvement.

Native image loaders process the image differently and usually do it faster. The reason the native image loader for PNG is not enabled by default is because it does not support all types of PNG images, but supports the most common, so very likely it will work with your images too.

Why is PNG more expensive than JPG to process? One reason is transparency, which JPG does not support. To embed a PNG in PDF the transparency bytes have to be separated from the RGB bytes, and then both are embedded in the PDF as separated components. The other reason is compression. When not using the native image loader, the PNG image needs to be uncompressed and converted to a "plain" RGB bitmap. This process can be very expensive.

On 10/16/13 7:39 PM, Roberto Cahanap wrote:
Hello everyone.

We have been trying to figure out why our pdf generation was taking so long.

When we changed an image in the PDF from PNG to JPG, then it was much faster.

Is there a difference in the way these two graphic formats are processed in FOP?

Thank you for your responses.

-Roberto


The information transmitted in this email and any of its attachments is intended only for the person or entity to which it is addressed and may contain BioReference Laboratories proprietary information, which is privileged, confidential, or subject to copyright belonging to BioReference Laboratories. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be unlawful. If you received this in error, please contact the sender immediately and delete and destroy the communication and all of the attachments you have received and all copies thereof.

Re: png vs. jpg

Posted by Luis Bernardo <lm...@gmail.com>.
Yes, there is a difference. By default FOP uses a "native" image loader 
for JPG but not for PNG. There is however a native image loader for PNG 
too, which you can enable in the configuration file. See 
http://wiki.apache.org/xmlgraphics-fop/HowTo/ImageLoaderRawPNG for more 
info. Try it and I expect that you will see a performance improvement.

Native image loaders process the image differently and usually do it 
faster. The reason the native image loader for PNG is not enabled by 
default is because it does not support all types of PNG images, but 
supports the most common, so very likely it will work with your images too.

Why is PNG more expensive than JPG to process? One reason is 
transparency, which JPG does not support. To embed a PNG in PDF the 
transparency bytes have to be separated from the RGB bytes, and then 
both are embedded in the PDF as separated components. The other reason 
is compression. When not using the native image loader, the PNG image 
needs to be uncompressed and converted to a "plain" RGB bitmap. This 
process can be very expensive.

On 10/16/13 7:39 PM, Roberto Cahanap wrote:
>
> Hello everyone.
>
> We have been trying to figure out why our pdf generation was taking so 
> long.
>
> When we changed an image in the PDF from PNG to JPG, then it was much 
> faster.
>
> Is there a difference in the way these two graphic formats are 
> processed in FOP?
>
> Thank you for your responses.
>
> -Roberto
>
> The information transmitted in this email and any of its attachments 
> is intended only for the person or entity to which it is addressed and 
> may contain BioReference Laboratories proprietary information, which 
> is privileged, confidential, or subject to copyright belonging to 
> BioReference Laboratories. Any review, retransmission, dissemination 
> or other use of, or taking of any action in reliance upon, this 
> information by persons or entities other than the intended recipient 
> is prohibited and may be unlawful. If you received this in error, 
> please contact the sender immediately and delete and destroy the 
> communication and all of the attachments you have received and all 
> copies thereof.
>