# [texhax] Using .png, .jpg, .gif

Uwe Lück uwe.lueck at web.de
Wed Aug 5 08:38:50 CEST 2009

```Bev,

sorry, I did not pay proper attention to the aspect of your posting
concerning `convert' in \DeclareGraphicsRule:

At 05:43 02.07.09, Beverley Eyre wrote:
>I'd like to get \DeclareGraphicsRule to work, but it seems more trouble to
>use than just converting each image file by hand.
>
>For example, if I want to use a .png file:
>\DeclareGraphicsExtensions{.png, .eps}
>\DeclareGraphicsRule{.png}{eps}{*}{`convert #1}      %% (the last arg I've
>done in many different ways, e.g. {`convert #1 eps:- } )
>
>then, in the body:
>
>\includegraphics[width=1in]{myimage}   %% (which is myimage.png)
>
>I get an error msg telling me that I there is no bounding box. So in order
>to use it, I have to determine the bounding box for the image first, and
>then include that info into one or the other command.   But, if I just do:
>
> > convert myimage.png myimage.eps
>
>on the command line, it converts it without having to know the bounding
>box info. I'm not sure why convert needs the bounding box info in one case
>(latex) but not the other (command line).

It is important to recognize that importing a graphics file with LaTeX has
two parts: 1. the LaTeX run (building a .dvi), 2. previewing or printing
(executing \special commands from the .dvi).

The LaTeX run only needs to know the dimensions of the image. This is where
the famous `bounding box' error occurs. LaTeX does not care about other
contents of the graphics file. This other content is only used at getting
visible output from the .dvi.

The command in the fourth argument is only used at the second step,
creating a screen display or printout from the .dvi. This is too late to
tell LaTeX the bounding box info!

Repeating:

>But, if I just do:
>
> > convert myimage.png myimage.eps
>
>on the command line, it converts it without having to know the bounding
>box info.

It is wrong to say `convert' doesn't need knowledge of the bounding box.
The truth is that `convert' is able to extract the bounding box information
from myimage.png while LaTeX is not.

>  I'm not sure why convert needs the bounding box info in one case (latex)
> but not the other (command line).

It is also wrong to say `convert' needs the bounding box info `in the LaTeX
case'. The error message comes from LaTeX when it looks for that info in
building the .dvi. As I said, `convert' is not involved at this first step.

HTH -- Uwe.

```