[l2h] Relative URLs in png/gif images

Ross Moore ross at ics.mq.edu.au
Thu Jun 5 11:07:03 CEST 2003


Hi Herb,

Given the sample coding that you provided, the 'feature'
(or lack thereof) is part of the coding for the package
that now handles the way \includegraphics is processed.

However, since your image is constant, (i.e. requiring no further
processing for use in your web-pages,) then you could recode
the definition of your \showimage command,
so that LaTeX2HTML does not need to handle the image at all, but just
create the relative link. Also, it doesn't need the information
about size and spacing.

e.g.
%begin{latexonly}
\newcommand{\showpng}[4][0.9\textwidth]{%
 ... the same coding that you have,
   ignoring the extra argument
}
%end{latex2html}
\begin{htmlonly}
\newcommand{\showpng}[4][]{%
 \begin{figure}[htb]
    \begin{center}
      \htmladdimg[center]{#4#2}
      \caption{\label{#2}#3}
    \end{center}
 \end{figure}
}
\end{htmlonly}

\begin{document}
 I'm going to include a png image right here:
 \showpng{l2h}{The figure caption}{../figs/}
\end{document}


The extra argument resolves the relative path from where
your HTML pages are placed, to where the image is located.
This is affected by Perl variables and command-line options,
so is not always easily deducible at run-time.


Hope this helps,

	Ross


On Wed, 4 Jun 2003, Herb W. Swan wrote:

> --===============61040300356847654==
> Content-Type: X-sun-attachment
>
> ----------
> X-Sun-Data-Type: text
> X-Sun-Data-Description: text
> X-Sun-Data-Name: text
> X-Sun-Charset: us-ascii
> X-Sun-Content-Lines: 122
>
>
> LaTeX2HTML uses an absolute path name when including a gif or
> png image.  These absolute paths will break when the entire
> document is moved to a different location or a different server.
> Relative URLs would be more portable and appropriate if the user
> specifies an image path relative to the document.
>
> I am using the following version of LaTeX2HTML (l2h):
>
> This is LaTeX2HTML Version 2002 (1.67)
> by Nikos Drakos, Computer Based Learning Unit, University of Leeds.
>
> My test program is as follows:
>
> -------------------------------------------------------------------------
>
> \documentclass[11pt]{article}
> \usepackage{graphicx}
> \usepackage{html}
> \DeclareGraphicsExtensions{png}
> \DeclareGraphicsRule{.png}{eps}{.bb}{`pngtopnm #1|pnmtops -noturn -rle}
> \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{\showpng}[3][0.9\textwidth]{%
>     \setlength{\gifwidth}{#1}
>     \begin{figure}[htb]
> 	\begin{center}
> 	    \vspace{1ex}
> 	    \includegraphics[width=\gifwidth]{#2.png} \\
> 	    \caption{\label{#2}#3}
> 	    \end{center}
> 	\end{figure}
>     }
>
> \begin{document}
> I'm going to include a png image right here:
> \showpng{l2h}{The figure caption}
> \end{document}
>
> -------------------------------------------------------------------------
>
> The image file I'm displaying (l2h.png) and associated bounding box
> (l2h.bb) are attached to this message if anyone is interested, but any
> image would work just as well.
>
> The HTML file generated by l2h specifies an absolute image URL:
>
> I'm going to include a gif image right here:
>
> <DIV ALIGN="CENTER"><A NAME="l2h"></A><A NAME="32"></A>
> <TABLE>
> <CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
> The figure caption</CAPTION>
> <TR><TD>
> <DIV ALIGN="CENTER">
> <BR>
> <BR>
> 	    <IMG
>  WIDTH="597" HEIGHT="190" ALIGN="BOTTOM" BORDER="0"
>  SRC="/h/lanhws/plano/text/www/test//l2h.png"
>  ALT="Image /h/lanhws/plano/text/www/test//l2h.png">
> <BR>
> </DIV></TD></TR>
> </TABLE>
> </DIV>
>
> -------------------------------------------------------------------------
>
> The problem may be corrected by adding a line to embed_image:
>
>     $url =~ s|^$texfilepath/*||o;       # HWS:  Make URLs relative
>     $urlimg = $url;
>     $urlimg =~ s/\.$IMAGE_TYPE$/.html/ if ($map);
>     if ($exstr =~ s/align\s*=\s*(\"?)(\w+)\1($|\s|,)//io) { $align = $2; }
>     my $usersize = '';
>
> -------------------------------------------------------------------------
>
> Now the HTML uses a portable relative URL to the image, although the
> ALT tag still contains an absolute URL:
>
> I'm going to include a gif image right here:
>
> <DIV ALIGN="CENTER"><A NAME="l2h"></A><A NAME="32"></A>
> <TABLE>
> <CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG>
> The figure caption</CAPTION>
> <TR><TD>
> <DIV ALIGN="CENTER">
> <BR>
> <BR>
> 	    <IMG
>  ALIGN="BOTTOM" BORDER="0" SRC="l2h.png"
>  ALT="Image /h/lanhws/plano/text/www/test//l2h.png">
> <BR>
> </DIV></TD></TR>
> </TABLE>
> </DIV>
>
> -------------------------------------------------------------------------
>
> This patch will also work if the image is not in the source directory,
> but in a \graphicspath directory that is relative to the source.
> Another logical extension would then copy the image (wherever it is)
> to the final document directory (creating the relative \graphicspath
> directory, if specified) when the -local_icons switch is set.
>
> Is this a worthy modification of l2h for a future release, or is there
> some workaround for the present code that would make this modification
> unecessary?
>
> Thank you all the work that has gone into maintaining l2h into the
> awesome product it is today!
>
> ----------
> X-Sun-Data-Type: default
> X-Sun-Data-Description: default
> X-Sun-Data-Name: l2h.png
> X-Sun-Encoding-Info: uuencode
> X-Sun-Content-Lines: 94
>
> begin 600 l2h.png
> MB5!.1PT*&@H    -24A$4@   E4   "^"      Y<:4&   /J$E$051XG.V=
> MW=&SNA''5YDTX,O<TH(+R TNX:D@,TX)4$$&EQ J.!F7 "6\2BHX3-+ <0GD
> M@@\MZ ,)5H#M_5V\YSF6D 3\D5;22A(M, PQ?SJZ ,P'PJIBZ&%5,?2PJAAZ
> M6%4,/:PJAAY6%4,/JXJAAU7%T,.J8NAA53'TL*H8>EA5##VL*H8>5A5##ZN*
> MH8=5Q=##JF+H854Q]+"J&'I850P]K"J&'E850P^KBJ&'5<70PZIBZ/ESS,2;
> M!N!ZB9D#<TJBJJI\ %1IS!R84Q*BJI=<B.!=+]4!N<X(%*FKS$FB_I:OY3B,
> M+R)@3YCZMA!A5B_=:@" K##DZI_IG, ];%QEQB6[681N*GV'TB'7QG.BMH ?
> M33[JD#=KFL-]P#740 at A5N0DA\@,+<T)"ZJHDZ_]XX%_3JXHPB5YW3<2K<9 at F
> MR<_D?W'"=VRD/1OO4LXR,):YRQBW7#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$[B!W)F3[+4GU.WWMLU@#ZB'8 at YH<1*C78$#A1:I
> M%=#G-\:=V"4"I: L%57!CK^I]]:J*UNMF).2"T!6Y1A%#$&H(&+,&"=E8!8J
> MAA_FS<)N'-\'%  MM-VG-U;LHG^Q0D#;PF( S%X##D02Z<0[O*1)W(E&.X.O
> M2Z%5[VJ()* =E3=FHZX4+8 02C]M+QE\10M]$55V*%WT&[H!'(P>R'AK0ZC
> M#^,04>VNJOYEC4]T?,< ZC'/_IXE$/8[#@CO#^$* +]E !"VY)#(5%Q#"><O
> M7$S^@])K+<'X%_1W_Y%TEUD?2U2.;@&[C_A :Q.UEUJ0L(=-KG=B3T"$OG*<
> M%+*7]K %PSA:50#0BL4=_]89\7[O3(#;HB6R_[6?1?A&AUITT0HEIID9>B3'
> MVU5..A/%\/"M 8N!,URM8M1!#T<EZ<MIM]\\N:J4L>P=L!AX#C8W^V>^P1.H
> M:FF21 AA^*:M 8[ H2?6Q3'\-4L#JW/>3^P[KL/%EI*T0X?54,#I70N5[J0(
> MKJ1:5<)9Z,&2.[(218^@'[Q!XW9H &C &*!&G)"!,7T=DV&@5HT:J3];P_M#
> M8SYC<?'%PQT,!6C%M(0"WQDNN1I9PP- at +4I._3:_#B;EF0P=#%';\)XN.:=M
> MFCO$Y!W[!'@&>N=_[N=S4D[0 KH9AQF] Q8#/1&3JH,)X/2J$K8!+6O 8F!0
> MYLP*3MX"]N_5+"ISP$*@L(:88I[\Z9R5LZN*>4=.WP(R;PBKBJ&'5<70PZIB
> MZ&%5,?2PJAAZ6%4,/:PJAAY6%4,/JXJAAU7%T,.J8NAA53'TL*H8>EA5##VL
> M*H8>5A5##ZN*H8=5Q=##JF+H854Q]+"J&'I850P]K"J&'E850\__ 7?R[:.R
> /SJ2-     $E%3D2N0F""
>
> end
> ----------
> X-Sun-Data-Type: default
> X-Sun-Data-Description: default
> X-Sun-Data-Name: l2h.bb
> X-Sun-Charset: us-ascii
> X-Sun-Content-Lines: 1
>
> %%BoundingBox: 19 289 593 472
>
> --
>
>
>
>  /-----------------------+-----------------------------------\
>  | Herbert Swan          | Geoscience Operations             |
>  | Phillips Alaska, Inc. |                                   |
>  | 700 G Street          | Phone:  (907) 263-4043            |
>  | Anchorage, AK  99501  | Fax:    (907) 265-1608            |
>  | Room:  ATO 1370       | e-mail: lanhws at expl.ak.ppco.com   |
>  \-----------------------+-----------------------------------/
>
>
>
> --===============61040300356847654==
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
>
> _______________________________________________
> latex2html mailing list
> latex2html at tug.org
> http://tug.org/mailman/listinfo/latex2html
>
> --===============61040300356847654==--
>


More information about the latex2html mailing list