# tex4ht: reuse png images instead of creating new ones

I have a lot of PNG images in my document, which (the document) I'd like to convert to HTML using tex4ht (htlatex). Now the images need to be in EPS format, as htlatex uses DVI mode. So I run convert foo.png foo.eps before I run htlatex. When generating the HTML, tex4ht creates a new PNG out of these EPS images, although I have the original which could (should) be used instead. That would save me quite some time and space.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\begin{document}

\section{something}
\includegraphics[width=5cm]{mill}
\end{document}


(mill.png is from the ConTeXt distribution, but could be any PNG file.)

-
I thought it was not so much DVI-mode that requires eps, but the latex command itself. pdflatex can also output dvi by using -output-format=dvibut I don't know if it helps in this situation. – Mikael Öhman Feb 4 '12 at 13:41
@MikaelÖhman that's an interesting thought, I'll do some research on that. – topskip Feb 4 '12 at 13:55

You must provide extension for your graphics file:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\begin{document}

\section{something}
\includegraphics[width=5cm]{mill.png}
\end{document}


This compiles fine without need for the eps step

-
But png files do not have bounding box? the width will be ignored when run by tex4ht, and original .png size will be used. I tried it on texlive 2013. Only pdflatex will scale the .png file, but not tex4ht – Nasser Jun 16 '14 at 6:16

I feel stupid, but I can answer my own question. With the following configuration file, htlatex uses EPS and pdflatex uses PNG:

\Preamble{html}
\begin{document}

\Configure{graphics*}
{eps}
{\Picture[pict]{\csname Gin@base\endcsname\PictExt}}

\EndPreamble


Save this file in whatever.cfg and call tex4ht with htlatex myfile whatever.

-