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 Je...@accessbusinessgroup.com on 2002/05/01 17:32:16 UTC

Memory consumption with large images in FOP

I just started a project using FOP for the dynamic creation of Marketing
Materials in PDF form, and with all of the talk about memory consumption, I
began wondering if anyone has had any experience with large images in FOP,
or knows how image processing in FOP works?  The marketing materials I'm
creating include product shots, which come out of our Digital Asset system
as approximately 50MB TIFFs.  I'm converting them to JPEGs, which brings
the actual file size down considerably, but I'm getting some weird results
after they go through the PDF Rendering process.  If I do the image as a
JPEG at full resolution (3990x4989 pixels), the resulting PDF has a black
rectangle, where the image should be.  If during the conversion to JPEG, I
cut the dimensions in half (to 1995x2495 pixels), the PDF shows the image.

Does anyone know why the larger image is showing up all black?  Is there a
limit to the resolution of raster images FOP (or PDFs in general) can
handle, or this perhaps a problem with memory?

It appears the images contained within a PDF are compressed.  Does anyone
know if this compression is JPEG, and if so, does FOP just dump a given
JPEG into the PDF file, or does it uncompress the original JPEG in memory,
and then recompress it to go into the PDF?  This information will help me
to optimize the input file format for memory, processing time, and image
quality.

Finally, I haven't found a definitive list of the image types allowed in an
external-graphic src attribute.  Does anyone know where I might find such a
list.

I apologize for the length of the post.  I just thought some background
information might help, rather than launching into my questions.  Any help
(either direct nswers, or sources that might provide clues) would be
greatly appreciated.

-Jeff


Re: Memory consumption with large images in FOP

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Jeff_Mitchell@accessbusinessgroup.com wrote:
> the resulting PDF has a black
> rectangle, where the image should be. 

In PDF, images are rendered at 1/72 inch per pixel, or roughly
3.53 cm per 100 pixel. Higher resolution images are scaled down
during rendering, you may see a resampling artifact, or simply
a bug (probably in the PDF viewer). Be aware that the PDF viewer
will have to decompress your 4k*5k pixel images at 3 bytes per
pixel, resulting in allocating nearly 60 MB or more.
It is also possible that you run into an arithmetic overflow
or some similar problem.

> Is there a
> limit to the resolution of raster images FOP (or PDFs in general) can
> handle, or this perhaps a problem with memory?

In theory, there is no limit, at least not directly imposed by FOP.
FOP will, however, hold the file in memory, decompressed for some
formats.

> It appears the images contained within a PDF are compressed.  Does anyone
> know if this compression is JPEG,  and if so, does FOP just dump a given
> JPEG into the PDF file, or does it uncompress the original JPEG in memory,
> and then recompress it to go into the PDF?

For JPEG images, the file is dumped into the PDF basically unchanged.

> Finally, I haven't found a definitive list of the image types allowed in an
> external-graphic src attribute.  Does anyone know where I might find such a
> list.


 From the sources: GIF, BMP, EPS and JPEG are supported natively, in
part through standard Java mechanisms. There are not necessarily all
subformats supported (BMP has at least a dozen, some very obscure,
and there are a few exotic JPEG subformats as well).
SVG is supported through Batik.
FOP can take advantage of the Jimi image library and of JAI. Jimi
is no longer distributed with FOP because of license reasons, you
can get it yourself (there are instructions in the docs), but for
some odd reasons it may be possible that you'll have to rebuild
FOP from the sources, even though this is very easy nowadays.
Jimi supports:  AFP (dunno), BMP, CUR (MS Windows cursor?), GIF,
ICO (Windows icons), PCX, PICT (dunno), PNG, PSD (dunno), Sun
raster (used by Sun), TGA, TIFF and XBM (X Windows bitmap).
JAI is an interface specification, FOP will support whatever your
JAI conformant implementation supports if you drop it in (may
require rebuild).
This list is not authoritative, apply usual disclaimers.

J.Pietschmann