[Tex/LaTex] When generating html, how do you specify image size

htlatexhtmltex4ht

I am using htlatex (or as many people call it tex4ht) to generate html and I have included some graphics. Htlatex seems to ignore all the size arguments I give the image size. I've tried specifying:

width=\textwidth
width=2in
width=1024px
width=1024pt

All of these have been ignored. Can you specify a size for the image when using htlatex to generate an html version of your document? If yes how does one specify the image size?

Right now I am editing each picture to be the correct size but this is bothersome… I would much rather have one high res picture and then specify a smaller size.

Best Answer

Following code will help you to grab the width and height dimensions of the graphic provided with your \includegraphics command:

 \makeatletter
    \Configure{graphics}
     {\bgroup
         \Configure{IMG}
            {\HCode{<img src="}}
            {\HCode{" alt="}}
            {" }
            {\HCode{" }}
            {}%
      \Picture+[PIC]{}}
     {\EndPicture
       \HCode{ width="\expandafter\the\csname Gin@req@width\endcsname"
       height="\expandafter\the\csname Gin@req@height\endcsname"
        />}%
      \egroup}
 \makeatother