List Info

Thread: Included images too big in fop PDF output




Included images too big in fop PDF output
user name
2007-07-18 10:21:50
Hi all,

thanks to the suggestions of John Shipman (see:
http://thread.gmane.org/gmane.text.docbook.apps/17584 

), I have a toolchain that converts tex equation files to
J-peg files,
which I include in the docbook source as media objects with
snippets
like this:

<equation>
  <title>Test equation</title>
  <mediaobject>
    <imageobject>
      <imagedata
fileref="equations/equation.jpg"/>
    </imageobject>
  </mediaobject>
</equation>

I'm using xsltproc and fop 0.93 to convert FO to PDF.

Output looks good in HTML format, but the images in the fop
PDF output
appear too big (50% or more bigger than the J-peg image as
rendered in
the HTML document or by an image viewer), and they can't be
contained
entirely in the page, so they overflow.

I also tried with EPS images with snippets like this:

<equation>
  <title>Test equation</title>
  <mediaobject>
    <imageobject role="html">
      <imagedata
fileref="equations/equation.jpg"/>
    </imageobject>
    <imageobject role="fo">
      <imagedata
fileref="equations/equation.eps"/>
    </imageobject>
  </mediaobject>
</equation>

but then the equation images don't appear at all in the PDF
output.

So it seems like a fop problem. Someone can suggest how to
overcome
this problem? 

An yes, I read this:
http://xmlgraphics.apache.org/fop/0.93/graphics.h
tml#resolution

and still can't figure out what to do to fix the problem.

Many thanks in advance.

Cheers.
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)

------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


Re: Included images too big in fop PDF output
user name
2007-07-18 12:33:20
Hi Stefano,

See also http://www.oasis-open.org/archives/docbook-a
pps/200704/msg00150.html

I've had this problem myself and have resolved it for screen
shots by
not setting any size information in the DocBook source, but
rather by
setting the resolution on the image files. For XEP, I've
found setting
the resolution on each image file (using your favorite
graphics
program or utility) to 120dpi seems to work pretty well. You
might
need to use a slightly different setting (72 or 96dpi) for
FOP.

HTH,

Ken


On 7/18/07, Stefano Sabatini <stefano.sabatini-lalaposte.it> wrote:
> Hi all,
>
> thanks to the suggestions of John Shipman (see:
> http://thread.gmane.org/gmane.text.docbook.apps/17584
>
> ), I have a toolchain that converts tex equation files
to J-peg files,
> which I include in the docbook source as media objects
with snippets
> like this:
>
> <equation>
>   <title>Test equation</title>
>   <mediaobject>
>     <imageobject>
>       <imagedata
fileref="equations/equation.jpg"/>
>     </imageobject>
>   </mediaobject>
> </equation>
>
> I'm using xsltproc and fop 0.93 to convert FO to PDF.
>
> Output looks good in HTML format, but the images in the
fop PDF output
> appear too big (50% or more bigger than the J-peg image
as rendered in
> the HTML document or by an image viewer), and they
can't be contained
> entirely in the page, so they overflow.
>
> I also tried with EPS images with snippets like this:
>
> <equation>
>   <title>Test equation</title>
>   <mediaobject>
>     <imageobject role="html">
>       <imagedata
fileref="equations/equation.jpg"/>
>     </imageobject>
>     <imageobject role="fo">
>       <imagedata
fileref="equations/equation.eps"/>
>     </imageobject>
>   </mediaobject>
> </equation>
>
> but then the equation images don't appear at all in the
PDF output.
>
> So it seems like a fop problem. Someone can suggest how
to overcome
> this problem?
>
> An yes, I read this:
> http://xmlgraphics.apache.org/fop/0.93/graphics.h
tml#resolution
>
> and still can't figure out what to do to fix the
problem.
>
> Many thanks in advance.
>
> Cheers.
> --
> Stefano Sabatini
> Linux user number 337176 (see http://counter.li.org)
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
> For additional commands, e-mail: docbook-apps-helplists.oasis-open.org
>
>

------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


Re: Included images too big in fop PDF output
user name
2007-07-19 05:55:36
On date Wednesday 2007-07-18 13:33:20 -0400, Ken Morse
wrote:
> Hi Stefano,
>
> See also 
> http://www.oasis-open.org/archives/docbook-a
pps/200704/msg00150.html
>
> I've had this problem myself and have resolved it for
screen shots by
> not setting any size information in the DocBook source,
but rather by
> setting the resolution on the image files. For XEP,
I've found setting
> the resolution on each image file (using your favorite
graphics
> program or utility) to 120dpi seems to work pretty
well. You might
> need to use a slightly different setting (72 or 96dpi)
for FOP.
>
> HTH,

Yes, it helped, thanks Ken!

Follows my analysis and solution for the archive.

The problem seems to be that the J-peg images I'm using
don't have
exif tags or other information to get their intrinsecs size,
and
fop seems to assume as default resolution 72dpi (that is:
2.83/mm),
while my screen has an effective resolution of about 96 dpi
(3.77/mm).

Applying that resolution to the J-peg files with a width in
picture of
about the half of my screen (1280 / 2 = 640) I get:

W_screen = W_pix  / screen_resolution = 
         = 640    / 3.77 mm ~= 170 mm

which is contained in an A4 paper (210x297 mm).

Fop computes the intrinsic width of the image applying the
default
resolution of 72dpi, resulting in:

W_fop = W_pix / assumed_image_resolution =
      = 640   / 2.83 ~= 227 mm

which overflows the A4 paper width size of 210 mm.

As you suggested there are two possible solutions:

1) set in the image file itself the resolution of the image
(I'm not
sure this is possible with every image format, but it is
with J-peg
ones where you can set the exif tags).

If you want the rendered intrinsic size of the image to be
equal to
that of the image viewed on the screen, you have to set the
resolution
of the image to that of the screen. In my case I measured
an
X-resolution of 1280 / (320 mm) = 4 / mm and an Y-resolution
of 800 /
(210 mm) = 3.81/mm, corresponding approximately to 96 dpi
(3.77/mm).

I tried to set it with exif but with no success:
 exif --set-value="x-Resolution=96dpi" idct.jpg 
'idct.jpg' does not contain EXIF data!

2) set in the XML source the viewport area, in my case I
want the
width not to overflow the width of an A4 paper (210 mm), so
I can
safely set for the content area a width of 160 mm.

<equation>
  <title>Inverse discrete cosine transforms
(IDCT)</title>
  <mediaobject>
    <imageobject role = "html" >
      <imagedata fileref="equations/idct.jpg"
/>
    </imageobject>

    <imageobject role = "fo" >
      <imagedata fileref="equations/idct.jpg"
                 contentwidth="160mm"
scalefit="1" />
    </imageobject>
  </mediaobject>
</equation>

The ideal would be to be able to set the size relatively to
the
maximum viewport size available, to get the rendered image
fits the
available space on the page without overflowing the
boundaries, while
the relative dimensions setted with contentwidth, width,
contentdepth,
etc (for example with contentwidth="66%") seem to
be relative to the
computed intrinsic size.

Is it possible to achieve this with docbook?

Cheers
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)

------------------------------------------------------------
---------
To unsubscribe, e-mail: docbook-apps-unsubscribelists.oasis-open.org
For additional commands, e-mail: docbook-apps-helplists.oasis-open.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )