You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Eric Dalquist <eb...@mtu.edu> on 2001/08/14 20:47:18 UTC

Request: Imbedded Image Compression

We have been using FOP in production to generate reports with Oracle's XSQL
servlet for about 1 month now and it has been working great. Our next
project is a photo ID class roster. The system is pretty much set but right
now the main thing holding us back is the size of the resulting PDF
document. An 8 page PDF with 30 1.5in x 1.13in jpegs on it is 7.18MB.
Considering the 240 images used in this document only occupy 730KB this is
rather large. The only other data in the document is a header and each
persons name. From what I have read on the FOP mailing list over the past
few months I seem to remember something about the cause of this being the
way Sun's JDK handled the images internally. I was also wondering if anyone
was working on incorporating some kind of image compression into FOP?

Our FO uses external-graphic tags to imbed the imaged

<fo:external-graphic height="1.5in" width="1.13in">
    <xsl:attribute name="src">

<xsl:text>http://localhost/xsql/Photo_Rosters/images/</xsl:text><xsl:value-o
f select="../STUDENT[($row_index*6) + $cell_index]/ID"/>
    </xsl:attribute>
</fo:external-graphic>


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Request: Imbedded Image Compression

Posted by Keiron Liddle <ke...@aftexsw.com>.
On Mon, 20 Aug 2001 20:28:22 Eric Dalquist wrote:
> Just to update everyone on my progress. I have made most of the changes
> needed to insert raw JPGs into PDFs generated by FOP. I still have a day
> or
> two of testing before I post what I have changed. I was wondering what
> the
> procedure is for posting a possible FOP patch. Some help or pointers on
> this
> part over the next few days would be helpfull. By the way, that 7.18MB
> PDF
> with 240 images is now 379KB.

This page here should tell you the information you need to know:
http://xml.apache.org/fop/involved.html

admittedly it is not complete and hasn't been updated for a while, so I
will attempt some elaboration.
Others can correct me if I'm going off in a completely wrong tangent.

Submitting a patch

Usually after making you changes to the code you should do a diff with the
current cvs.
Then you should attach (not inline) the diff to an email message to the
mailing list. If it is (very) large  you may want to compress it or put it
on a website. Usually an email is fine.

Code format

The code should follow the same format as the rest of the FOP code (4 space
indent etc.)

The email

You will probably want to explain the your email briefly what the patch is
about, have a relevant subject (eg. [PATCH] jpg images in pdf).

You should try to test it (obviously) and if possible it would be good to
supply some examples/tests.

----
Sounds good, a large saving on file size. This will probably need to be
supported sometime for jpg images in svg (I you aren't already doing that).

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Request: Imbedded Image Compression

Posted by Eric Dalquist <eb...@mtu.edu>.
Just to update everyone on my progress. I have made most of the changes
needed to insert raw JPGs into PDFs generated by FOP. I still have a day or
two of testing before I post what I have changed. I was wondering what the
procedure is for posting a possible FOP patch. Some help or pointers on this
part over the next few days would be helpfull. By the way, that 7.18MB PDF
with 240 images is now 379KB.

-Eric Dalquist


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Request: Imbedded Image Compression

Posted by Eric Dalquist <eb...@mtu.edu>.
Thanks for the information. I'll look into making the changes to bypass the
decompression for jpegs and just embed the image, without breaking other
stuff hopefully. If it all works out well I'll post may changes.

-Eric Dalquist

----- Original Message -----
From: "Jeremias Maerki" <je...@outline.ch>
To: <fo...@xml.apache.org>
Sent: Tuesday, August 14, 2001 4:27 PM
Subject: Re: Request: Imbedded Image Compression


> > We have been using FOP in production to generate reports with Oracle's
XSQL
> > servlet for about 1 month now and it has been working great. Our next
> > project is a photo ID class roster. The system is pretty much set but
right
> > now the main thing holding us back is the size of the resulting PDF
> > document. An 8 page PDF with 30 1.5in x 1.13in jpegs on it is 7.18MB.
> > Considering the 240 images used in this document only occupy 730KB this
is
> > rather large. The only other data in the document is a header and each
> > persons name. From what I have read on the FOP mailing list over the
past
> > few months I seem to remember something about the cause of this being
the
> > way Sun's JDK handled the images internally. I was also wondering if
anyone
> > was working on incorporating some kind of image compression into FOP?
>
> Currently all images are decoded into memory as an uncompressed array of
> pixels which then get written (and compressed) to the target file. For
> PDF the compression is ZLib (Flate/Deflate). For JPEG this is very
> inefficient. Theoretically, PDF supports the embedding of native JPEG
> files. This is described in the PDF specs. The clue now would be to
> write code that bypasses the decompression/compression phases that
> happen at the moment. That will probably cause changes in the
> org.apache.fop.image and org.apache.fop.render.pdf packages.
>
> I've once started looking into it but never got enough time to really
> implement it. I'll be away on holidays the next two weeks so I'm not
> much of a help right now.
>
> I can only give some pointers, though:
> - The PDF spec contains information on how to implement JPEG-embedding.
> - JPEG-support in PDF is very similar to JPEG-support in PostScript.
> - And for PostScript there is a demo application on how to embed a JPEG
> image in a PostScript file. This can be easily adapted to PDF. See the
> link below.
> - There's a JPEGReader class that's already parsing the JPEG headers
> (org.apache.fop.image.analyser.JPEGReader).
>
> By the way, your request is already on the todo list.
>
> PDF specs at:
> http://partners.adobe.com/asn/developer/acrosdk/docs.html
>
> JPEG2PS at (in German):
> http://www.pdflib.com/jpeg2ps/
>
> Good luck!
>
> Jeremias Märki
>
> mailto:jeremias.maerki@outline.ch
>
> OUTLINE AG
> Postfach 3954 - Rhynauerstr. 15 - 6002 Luzern
> Fon +41 (0)41 317 2020 - Fax +41 (0)41 317 2029
> Internet http://www.outline.ch
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Request: Imbedded Image Compression

Posted by Jeremias Maerki <je...@outline.ch>.
> We have been using FOP in production to generate reports with Oracle's XSQL
> servlet for about 1 month now and it has been working great. Our next
> project is a photo ID class roster. The system is pretty much set but right
> now the main thing holding us back is the size of the resulting PDF
> document. An 8 page PDF with 30 1.5in x 1.13in jpegs on it is 7.18MB.
> Considering the 240 images used in this document only occupy 730KB this is
> rather large. The only other data in the document is a header and each
> persons name. From what I have read on the FOP mailing list over the past
> few months I seem to remember something about the cause of this being the
> way Sun's JDK handled the images internally. I was also wondering if anyone
> was working on incorporating some kind of image compression into FOP?

Currently all images are decoded into memory as an uncompressed array of
pixels which then get written (and compressed) to the target file. For
PDF the compression is ZLib (Flate/Deflate). For JPEG this is very
inefficient. Theoretically, PDF supports the embedding of native JPEG
files. This is described in the PDF specs. The clue now would be to
write code that bypasses the decompression/compression phases that
happen at the moment. That will probably cause changes in the
org.apache.fop.image and org.apache.fop.render.pdf packages.

I've once started looking into it but never got enough time to really
implement it. I'll be away on holidays the next two weeks so I'm not
much of a help right now.

I can only give some pointers, though:
- The PDF spec contains information on how to implement JPEG-embedding.
- JPEG-support in PDF is very similar to JPEG-support in PostScript.
- And for PostScript there is a demo application on how to embed a JPEG
image in a PostScript file. This can be easily adapted to PDF. See the
link below.
- There's a JPEGReader class that's already parsing the JPEG headers
(org.apache.fop.image.analyser.JPEGReader).

By the way, your request is already on the todo list.

PDF specs at:
http://partners.adobe.com/asn/developer/acrosdk/docs.html

JPEG2PS at (in German):
http://www.pdflib.com/jpeg2ps/

Good luck!

Jeremias Märki

mailto:jeremias.maerki@outline.ch

OUTLINE AG
Postfach 3954 - Rhynauerstr. 15 - 6002 Luzern
Fon +41 (0)41 317 2020 - Fax +41 (0)41 317 2029
Internet http://www.outline.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org