[l2h] Already generated image inclusion

Ross Moore ross@ics.mq.edu.au
Tue, 7 Jan 2003 09:21:44 +1100 (EST)


Hi Herb,

Great to hear from you after so long.

> 
> 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."

Yes.
The latest versions of LaTeX2HTML have revamped graphics.perl
and graphicx.perl via a new module  graphics_support.perl
written by Bruce Miller of NIST.

> In this example, my already generated images are in gif format,
> and are located in the "snaps" directory relative to my latex
> source.
> 
> %
> %  Allow the insertion of gif images from the snap directory.
> %
> \usepackage{graphicx}
> \DeclareGraphicsExtensions{gif}
> \DeclareGraphicsRule{.gif}{eps}{.bb}{`giftopnm #1|pnmtops -noturn -rle}
> \graphicspath{{snaps/}}
> \newlength{\gifwidth}
> %
> %  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}
> %
> \newcommand{\showimage}[3][0.9\textwidth]{%
>     \setlength{\gifwidth}{#1}
>     \begin{figure}[htb]
> 	\begin{center}
> 	    \vspace{1ex}
> 	    \includegraphics[width=\gifwidth]{#2.gif} \\
> 	    \caption{\label{#2}#3}
> 	    \hrulefill\htmlrule
> 	    \end{center}
> 	\end{figure}
>     }
> 
> 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

Bruce's coding allows support of many more graphics formats. It first
determines whether a conversion is necessary or not, by looking at the
filename suffix for whatever files it can find in the local directory
having the correct prefix, then it makes use of many more of the various
netpbm modules to do any required conversions or transformations.
Essentially *all* of the options to LaTeX's \includegraphics command are
supported, including rotations, scaling and cropping to a specified size.

 
> 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!

It gets a bit of tinkering when someone reports abnormal behaviour which
can be traced to being a real bug. (That doesn't happen very much anymore,
thanks to the great work that has been put in over the years by many people,
yourself included.)


All the best, and have a great New Year

	Ross



> 
> 
> 
> 
> --
> 
> 
> 
>  /-----------------------+-----------------------------------\
>  | 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  |
>  \-----------------------+-----------------------------------/
> 
> 
> _______________________________________________
> latex2html mailing list
> latex2html@tug.org
> http://tug.org/mailman/listinfo/latex2html