Re: [l2h] Relative URLs in png/gif images
Herb W. Swan wrote: 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've lost track of which version is which (my RH9 installation includes an odd, partly old version: This is jLaTeX2HTML Version 2002 (1.62) JA patch-1.4 but I would think the one you cite would include the modified graphic(s|x) packages. The _should_ generate a url to the image relative to the generated page in cases like yours Unless perhaps the extra centering, or space, or probably the computed width=\foo ... or whatever is confusing latex2html enough that it's just punting to LaTeX to process the entire environment. Certainly in simpler cases, eg \includegraphics[width=anythingexplicit]{#2} it should discover the .png, possibly do some simple image processing (eg rotations), copy the image to destination, if needed, and generate a relative url to it. (omitting the image type is preferred so both LaTeX, pdflatex, latex2html, etc can find the most appropriate type) I apparently don't have a decent/recent version to test on, but that's the way it was _supposed to work when I wrote it (wasn't it actually _your_ original code that I adapted!) 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} ___ latex2html mailing list [EMAIL PROTECTED] http://tug.org/mailman/listinfo/latex2html
Re: [l2h] Relative URLs in png/gif images
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=CENTERA NAME=l2h/AA NAME=32/A TABLE CAPTION ALIGN=BOTTOMSTRONGFigure 1:/STRONG The figure caption/CAPTION TRTD 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=CENTERA NAME=l2h/AA NAME=32/A TABLE CAPTION ALIGN=BOTTOMSTRONGFigure 1:/STRONG The figure caption/CAPTION TRTD 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
Re: [l2h] Relative URLs in png/gif images
On Wed, 4 Jun 2003, Herb W. Swan wrote: Thanks, Ross, for your prompt reply. I tried your suggestion, but it fell a bit short of expectations: What happened was that l2h still tried to convert the image with pstoimg. Of course it failed, since the image was empty as far as LaTeX was concerned. OK, yes; it tried to make an image of the {figure} environment. To prevent this, simply insert an empty {makeimage} environment inside the figure; hence within your macro definition, as shown below. This is the way to tell LaTeX2HTML to make an image just of the specified portion of the {figure}, and interpret anything else. Of course an image is made *only* if the specified portion is not just whitespace. \begin{htmlonly} \newcommand{\showpng}[4][]{% \begin{figure}[htb] \begin{center} \begin{makeimage} \end{makeimage} \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}{../} \end{document} % Hope this helps, Ross beagle% l2h test37 Note: Loading ./.latex2html-init Note: Initialising with file: .latex2html-init This is LaTeX2HTML Version 2002 (1.67) by Nikos Drakos, Computer Based Learning Unit, University of Leeds. Revised and extended by: Marcus Hennecke, Ross Moore, Herb Swan and others ...producing markup for HTML version 3.2 Loading /h/lanhws/l2h/versions/html3_2.pl *** processing declarations *** Loading /h/lanhws/l2h/versions/latin1.pl OPENING /h/lanhws/plano/text/www/test/test37.tex Note: Working directory is /h/lanhws/plano/text/www/test/test37 Note: Images will be generated in /tmp/l2h9626 texexpand V2002 (Revision 1.11) Loading /h/lanhws/l2h/styles/texdefs.perl... Loading /h/lanhws/l2h/styles/article.perl Loading /h/lanhws/l2h/styles/graphicx.perl Loading /h/lanhws/l2h/styles/html.perl Reading ... %,++. @ Reading aux file: /h/lanhws/plano/text/www/test/test37.aux ... Processing macros ...++.. Translating ... 0/1:top of test37: for test37.html *** translating preamble *** ... *** preamble done *** ;,.; 1/1:sectionstar:..About this document ... for node1.html ;;. Writing image file ... This is TeX, Version 3.1415 (C version 6.1) (images.tex LaTeX2e 1997/12/01 patch level 2 *** processing 1 images *** Generating postscript images using dvips ... This is dvips 5.72 Copyright 1997 Radical Eye Software (www.radicaleye.com) ' TeX output 2003.06.04:1704' - /tmp/l2h9626/image (- /tmp/l2h9626/image001) texc.prospecial.procolor.pro[1] Converting image #1 pstoimg: Error: /h/lanhws/bin/sun5/pnmcrop /tmp/l2h9626/p9644.pnm | /h/lanhws/bin/sun5/ppmquant -floyd 256 | /h/lanhws/bin/sun5/pnmtopng -interlace img1.png failed: Illegal seek Error while converting image: No such file or directory Doing section links .. *** Adding document-specific styles *** Done. Not only that, but it didn't even make a link to my image: I'm going to include a png image right here: DIV ALIGN=CENTERA NAME=l2h/AA NAME=27/A TABLE CAPTION ALIGN=BOTTOMSTRONGFigure 1:/STRONG The figure caption/CAPTION TRTD/TD/TR /TABLE /DIV BRHR !--Table of Child-Links-- I recall having tried several combinations of \begin{htmlonly}, \begin{latexonly}, etc. but the one which seemed to work best was my original post. It's one big disadvantage is that it relies on a nonstandard LaTeX2HTML, and we both know that there are too many of those floating about already! -- /---+---\ | 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: [EMAIL PROTECTED] | \---+---/ ___ latex2html mailing list [EMAIL PROTECTED] http://tug.org/mailman/listinfo/latex2html
Re: [l2h] Relative URLs in png/gif images
On Wed, 4 Jun 2003, Ross Moore wrote: OK, yes; it tried to make an image of the {figure} environment. To prevent this, simply insert an empty {makeimage} environment inside the figure; hence within your macro definition, as shown below. This is the way to tell LaTeX2HTML to make an image just of the specified portion of the {figure}, and interpret anything else. Of course an image is made *only* if the specified portion is not just whitespace. \begin{htmlonly} \newcommand{\showpng}[4][]{% \begin{figure}[htb] \begin{center} \begin{makeimage} \end{makeimage} \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}{../} \end{document} % Thanks, Ross. That did the trick. And it was a trick. I don't think I would have come up with it on my own. I would say that the coding that Bruce Miller made possible through his modifications to graphicx.perl are more straight-forward and more likely to be stumbled upon by an average user. He claims his modifications should have produced relative URLs. It might be worth investigating why they did not in my case. Could it have something to do with the way I configured LaTeX2HTML? If there's anything I can do to help, please let me know. -- /---+---\ | 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: [EMAIL PROTECTED] | \---+---/ ___ latex2html mailing list [EMAIL PROTECTED] http://tug.org/mailman/listinfo/latex2html
Re: [l2h] Relative URLs in png/gif images
Herb W. Swan wrote: [...] Thanks, Ross. That did the trick. And it was a trick. Ross comes up with some pretty amazing stuff, doesn't he! I don't think I would have come up with it on my own. I would say that the coding that Bruce Miller made possible through his modifications to graphicx.perl are more straight-forward and more likely to be stumbled upon by an average user. He claims his modifications should have produced relative URLs. It might be worth investigating why they did not in my case. Could it have something to do with the way I configured LaTeX2HTML? If there's anything I can do to help, please let me know. I downloaded the latest l2h (latex2html-2002-2-1, dated May 23,2003) and ran your test case. After futzing with the image -- I think my mailer didn't quite believe it was a png image, so when I tried to save it it came out partly corrupt. And l2h surprized me slightly by loading graphicxx.perl and complaining about graphicx not implemented... But anyway, it produced a test.html which contains: IMG WIDTH=597 HEIGHT=190 ALIGN=BOTTOM BORDER=0 SRC=./l2h.png ALT=Image l2h so it came out relative, in my case. Oh, I just noticed your example produced: SRC=/h/lanhws/plano/text/www/test//l2h.png Is that, by any chance, /h/... as in H:\... as in (you know what OS)? If so, it may well be that the pathname arithmetic is falling on its face I was concerned about that when writing it: I didn't want to introduce any new dependences on some of the (supposedly portable) File modules (that occasionally don't work right anyway)... and I'm vaguely recalling there was some operation I needed that wasn't quite in the L2hos stuffand having no way to test it. That may be where the problem is. OBTW: I just noticed I was subscribed by an obsolete form of my email address; I think I've got it sorted now ... Sorry you've got to approve me, Ross!! : Bruce ___ latex2html mailing list [EMAIL PROTECTED] http://tug.org/mailman/listinfo/latex2html