[l2h] graphicx.perl

Bruce Miller bruce.miller@nist.gov
Wed, 24 Jan 2001 16:38:59 -0500

"Ulrich G. Wortmann" wrote:
> ...   what about having a
> modification to graphicspath called \l2hgraphicspath.

That sounds like it might be part of the solution...

Hi Uli, Ross; 
Your comments, and Ross' offline got me thinking that although the
basic idea is good, a bit more is needed to do it robustly.

First, the Easy stuff:
 1) Once it's sorted out, we can handle graphics as well as graphicx.
 2) The way I coded it, we'll ultimately need get_image_size to support
    I've patched it, but I borrowed a code snippet to extract jpeg sizes
    -- I'd like to ask permission from the author before submitting it,
     unless we've already got such code in-house?
 3) The code has two general purpose subs find_file & maybe_copy_image
    are perhaps a bit too `Unixy' for general consumption. 
    OTOH, they are reasonable candidates for general use in l2h, perhaps
    part of L2hos?  A feature I'm fond of is that the copy only gets
done if the
    src file is newer, and it preserves timestamps.

As for the ALT attribute:
  Ross was suggesting a way of using \htmlimage to pass the info.
  This is probably necessary for some cases, but my general philosophy
of l2h 
  is to extract as much from `standard latex markup' as possible.
  Would it be feasable, at least in figure env, to infer which \caption
  applies and use that text for the alt?
Now for the harder stuff;
  I read more carefully through \includegraphics' options and tried to
imagine the scenarios.  It really simplifies to just two cases of
`Authors intent' (assuming both types of images are found):

  1) The pixel image has been prepared by hand, or is in some other way 
     preferable, _as_is_, to the converted eps image.  eg. size info is 
     only there to fit it on paper.    
  2) The pixel and eps images are equivalent, and the various
     scaling/clipping/etc options are essential to the `correct
[and both cases could be present in the same document!]

Case 1 is what I've implemented: _ignore_ any/all options and reuse the
existing pixel image.

Case 2: If the options can be handled [*], we'd generate a 
modified <IMG> tag and/or a modified image. Otherwise, fall back to
Of course, an author may also want to forbid us from even trying.

So, how does the author express his/her intent?
Maybe something like:
     perl               latex
  @GRAPHICS_PATH    \graphicspath    : where to look for images.
  @LTHGRAPHICS_PATH \lthgraphicspath : where to look for `as-is' images.

      'latex' : always pass to latex.
      'asis'  : use them as-is (case 1) search in both paths.
      '????'  : images in graphicspath are treated as case 2
                       in l2hgraphicspath are treated as case 1

Perhaps that covers most cases, but it's as clear as mud!
Any better suggestions?

[*] A note on handling the options:  
   Some are simple (eg. scale,width,height).  Others are not doable w/o 
transforming the image itself (eg. clip, rotate).  And, since the
are essentially transformation operations, you've got to handle the 
entire sequence of options, in order, if you handle any.
Worse, some options can't reasonably be simulated in HTML whether we do
in perl, or pass to latex.  For example, setting the bounding boxes,
w/o clipping can cause the image to overlap neighboring text (unless we
to layers... ugh)

My inclination would be to decline handling any options in version 1,
or at most handle cases where only the trivial ones are used, and leave
it to a pbm wiz to implement the extra operations later.

Bruce Miller
<bruce.miller@nist.gov>  http://math.nist.gov/~BMiller/