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

Uwe Lück uwe.lueck at web.de
Thu Aug 6 12:40:13 CEST 2009


Bev,

At 23:07 05.08.09, Beverley Eyre wrote:
>Ok, given that the situation is as you describe it, the next obvious 
>question is, since LaTeX (or the graphicx package)  goes to the trouble to 
>find the bounding box info for [e]ps files, can we get it to get it to 
>find the bounding box info from .png or .jpg files? We know it can be done 
>because both convert and pdflatex do it. This sounds like a question of a 
>few lines of code, no?

It will work for limited image file sizes only (may be ok for a usually 
small page).

What I like most is the ebb program since it just extracts the bounding box.

But to do the same with TeX, the first thing is knowing the algorithms ebb 
uses. I don't have any idea of them.

Moreover, TeX would have to do calculations that are described in the code 
of ebb in quite an efficient way. Calculating with TeX has a tendency to be 
clumsy -- well some macros can improve this. But the TeX code won't be 
shorter than the source code of ebb, so I don't expect that it will be a 
few lines of code. Even the lines in graphics.sty for reading the bounding 
box from .eps are not "few", I would say.

-- Uwe.

______________________________________
>Uwe Lück wrote:
>>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.
>>
>>_______________________________________________
>>TeX FAQ: http://www.tex.ac.uk/faq
>>Mailing list archives: http://tug.org/pipermail/texhax/
>>More links: http://tug.org/begin.html
>>
>>Automated subscription management: http://tug.org/mailman/listinfo/texhax
>>Human mailing list managers: postmaster at tug.org



More information about the texhax mailing list