# make4ht/ODT: resizing of images

There have already been several questions regarding the resizing of images with ht4leax/make4ht, but somehow none of the answers seems to resolve my problem.

Consider the following MWE

\documentclass{article}
\usepackage{graphicx}
\RequirePackage[]{fontspec}
\begin{document}
\begin{figure}
\includegraphics[width=\textwidth]{test.jpg}
\end{figure}
\end{document}


I compile this document with the following make4ht call to create a .odt file:

make4ht -l -u -f odt test.tex

I tried all kind of different config files, I tried without and without .xbb files, but no matter what I do, the parameter given with \includegraphics is ignored and the size of the embedded image in the final document stays the same.

The image dimension itself is set correctly, but it is embed in draw:frame element, which has wrong dimensions. I've found that this dimension is inserted by Xtpipes, which reads the image dimension from the image file itself and ignores the dimensions set in the TeX file:

<draw:frame draw:name="film.jpg" text:anchor-type="as-char" draw:z-index="0" svg:width="41pt" svg:height="41pt"><draw:image xlink:href="Pictures/film.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" svg:width="345.0pt" svg:height="345.1135pt"/><!--draw:name="IMG"
svg:width="345.0pt" svg:height="345.1135pt"
--></draw:frame>


It is possible to use make4ht filters to set the dimension in the draw:frame element to be the same as the dimension in the draw:image. Try the following build file:

local domfilter = require "make4ht-domfilter"

local domprocess = domfilter {
function(dom)
print("process images")
local frames  = dom:query_selector("draw|frame")
print("frames", #frames)
for _, frame in ipairs(frames) do
local images = frame:query_selector("draw|image")
if #images > 0 then
local image = images[1]
local width = image:get_attribute("svg:width")
local height = image:get_attribute("svg:height")
frame:set_attribute("svg:width", width)
frame:set_attribute("svg:height", height)
print("image dimensions", width, height)
end
end
return dom
end
}

Make:match("4oo", domprocess)


It is still necessary to generate the xbb file using

ebb -x test.jpg


Sample result:

• Thanks! That seems to do the trick. Any idea why this isn't standard behaviour? – Simifilm Aug 27 '18 at 13:24
• @Simifilm I've added this to the development version of make4ht. I think no one reported this issue before – michal.h21 Aug 27 '18 at 16:36