# tex4ht, html output: increase eps image resolution without affecting math images size

I have the following MWE:

\documentclass{book}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}
Lorem ipsum dolor sit amet, $$k_\delta=\frac{3 \mathit{EJ}}{l^3}$$ consectetur:
\begin{equation*}k_\delta=\frac{3 \mathit{EJ}}{l^3}\end{equation*}

\begin{centering}
\includegraphics[width=0.5\textwidth]{myimage.eps}
\end{centering}
\end{document}


which compiles fine to html (with htlatex example.tex "myconfig, xhtml, charset=utf-8" " -cunihtf -utf8" under Ubuntu TeXLive), myconfig.cfg being

\Preamble{xhtml}
\Configure{graphics*}
{jpg}
{\Picture[pict]{\csname Gin@base\endcsname .jpg
\space width="\expandafter\the\csname Gin@req@width\endcsname"}}
\Configure{graphics*}
{png}
{\Picture[pict]{\csname Gin@base\endcsname .png
\space width="\expandafter\the\csname Gin@req@width\endcsname"}}
\begin{document}
\EndPreamble


Looking for a workaround to the unsolved problem of small image sizes in html output, I wrote a Python script which parses html source and doubles width and height of all images, getting in face of a new problem, poor quality of 'doubled' eps images. So I tried to increase density from 110x110 to 220x220 in tex4ht.env, <convert> section:

Gconvert -trim +repage -density 220x220 -transparent '#FFFFFF' zz%%4.ps %%3


This actually increased the resolution of eps images, so that now I can double their size in html source with my Python script, but also increased the size of math formula images (whose size is not affected by my Python script because they don't hold width nor height attributes).

Is there a way to increase eps images resolution without affecting math images size?

Here is a screenshot of the html output with doubled size of math formulas:

-

It seems I managed to find a solution by myself. I rolled back the change to tex4ht.env, so that math formulas rendered as image are safe now, and I added the following section to my above mentioned preamble myconfig.cfg:

\Configure{graphics*}
{eps}
{\Needs{"convert -density 110x110 \csname Gin@base\endcsname.eps \csname Gin@base\endcsname.png"}
\Picture[pict]{\csname Gin@base\endcsname.png}}


This way eps images are managed in a different way (dvi code is bypassed, as said here), so that now they lack width attribute in html source; however such lack is perfectly fine because now eps images look bigger in html output, their size is satisfactory and they don't need to be "externally" enlarged through my post-production Python script.

Here is a screenshot of original example after solution:

I actually discovered that, although above solution is able to enlarge eps images, their size is independent from the size specified in LaTeX source, and inconsistent with jpg and png images, which retain the width and height in html output. If you are looking for a consistent solution, the eps section of myconfig.cfg should be

\Configure{graphics*}
{eps}
{\Needs{"convert -density 110x110 \csname Gin@base\endcsname.eps \csname Gin@base\endcsname.png"}
\Picture[pict]{\csname Gin@base\endcsname.png
\space width="\expandafter\the\csname Gin@req@width\endcsname"}}


This way width and height attributes in html output are retained also for eps images, and their size is consistent with jpg and png images, as I describe also in the problem I cited before.

-
Why not just use the geometry option as in: Gconvert -trim +repage -density 220 -geometry 50% -transparent '#FFFFFF' zz%%4.ps %%3 or the resample option as in Gconvert -trim +repage -density 220 -resample 120 -transparent '#FFFFFF' zz%%4.ps %%3 – Nasser Dec 31 '13 at 23:02
I tried your code but they did not work, at least for me. – mmj Jan 1 '14 at 9:22
No problem. It works for me just fine. Gconvert -trim +repage -density 220 -geometry 50% -transparent '#FFFFFF' zz%%4.ps %%3` is also documented here tug.org/applications/tex4ht/mn3.html "Increase the density (number of dots per inch) when converting the pictures, and then sub-sample the picture." – Nasser Jan 1 '14 at 13:27