[l2h] Already generated image inclusion

Herb W. Swan lanhws@expl.ak.ppco.com
Mon, 6 Jan 2003 10:49:49 -0900 (AKST)

I just stumbled on this possible solution to a previously posted
question of how to include an already generated (bitmap) image
into both the html and ps versions of the document.  It is not
documented, but it works too well for it not to have been a
designed "feature."

In this example, my already generated images are in gif format,
and are located in the "snaps" directory relative to my latex

%  Allow the insertion of gif images from the snap directory.
\DeclareGraphicsRule{.gif}{eps}{.bb}{`giftopnm #1|pnmtops -noturn -rle}
%  The \showimage command displays a gif image in html,
%  and a PostScript version of it in the ps document.  The optional
%  argument 'width' overrides the natural width of the image.
%  Usage:  \showimage{image}{caption}
%          \showimage[width]{image}{caption}
	    \includegraphics[width=\gifwidth]{#2.gif} \\

Apparently, latex2html is smart enough to not attempt to convert
an image with the .gif extension into PostScript.  Instead, it
simply inserts the image reference into the html file.  The latex
version instructs dvips to convert the gif to PostScript on the fly.
It does, however, require you to precompute the size of the gif
file in a nonbinary format that latex can read.  You can do this
in a makefile via

%.bb:   %.gif
	giftopnm $< | pnmtops -noturn -rle | grep BoundingBox > $@

and listing the .bb files as dependencies to the .dvi file.

You might try this with .png images by making the appropriate
changes to the \showimage macro, and declaring a different
GraphicsRule to convert png to ps.

PS - I can see that a lot of improvements have been made to lates2html
since the lst time I worked it.  Ross, I'm glad to see that you're
still very actively involved!


 | Herbert Swan          | Geoscience Operations             |
 | Phillips Alaska, Inc. |                                   |
 | 700 G Street          | Phone:  (907) 263-4043            |
 | Anchorage, AK  99501  | Fax:    (907) 265-1608            |
 | Room:  PTO 1340       | e-mail: lanhws@expl.ak.ppco.com  |