# frame option from adjustbox does not work in tex4ht

This MWE works in pdf. It puts frame around an image. But in HTML I see no frame produces

\documentclass[12pt]{article}%
\usepackage{graphicx}
\begin{document}
\includegraphics[width=0.5\textwidth,frame=0.1in]{A.png}
\end{document}


Compiled using lualatex foo4.tex gives

But compiled using make4ht foo4.tex gives this. No frame and some scratch line at bottom right corner

Source code produced looks wrong

<!DOCTYPE html>
<html lang="en-US" xml:lang="en-US" >
<meta  charset="iso-8859-1" />
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" type="text/css" href="foo4.css" />
<meta name="src" content="foo4.tex" />
>
<!--l. 10--><p class="noindent" > <img
src="A.png" alt="PIC"
/>_
__
</p>

</body>
</html>


I know I can use fbox to put a frame around an image and this works in tex4ht:

 \fbox{\includegraphics[width=0.5\textwidth]{A.png}}


but I wanted to use frame instead for other purposes. I could always use fbox in tex4ht mode and use frame in pdf mode. So I have a workaround for this, but was hoping to avoid this complication and use same code for both if possible.

Is there a way to make frame work in tex4ht also?

ps. I could not use the example images that come with latex for the MWE above, since these do not work with tex4ht for some reason. Path issue it seem, so I used my own image. Here is copy of A.png if you need to use it or any other image can be used.

https://www.12000.org/tmp/051119/A.png

You can try this version of adjustbox.4ht:

\NewConfigure{AdjustboxValignTop}{1}

% make an unique ID for each adjustbox environment

% suppress trying to draw the frame

% we should redefine all adjustbox environments, they may produce unvanted artifacts, math mode, etc.
% keys are set, so it should be possible to extract  colors or frame size in theory
% I just haven't found a working solution yet

% definitions for macros
% we don't save any colors and just use one configuration for all box types.



It generates unique ID for each adjust box, so it can be then styled using CSS. The configuration can look like this:

\Preamble{xhtml}

\Configure{halignTR}{}
\makeatletter
\def\pttoem#1{\strip@pt\dimexpr#1/\f@size em}
\makeatother
\begin{document}
\EndPreamble


The interesting part is this:

\def\pttoem#1{\strip@pt\dimexpr#1/\f@size em}

It defines command \pttoem that converts TeX dimensions to em, because it is better to use relative units in CSS. <div class="adjustbox"> with unique ID from \AdjusboxID is constructed for each adjustbox. CSS with border size and padding is created for each box.