Rotation in image Exif data not parsed

Max Chernoff tex at maxchernoff.ca
Wed Oct 30 02:01:23 CET 2024


Hi Jordan, Karl,

On Tue, 2024-10-29 at 16:48 -0600, Karl Berry wrote:
> If anyone is interested enough to come up with patches, ideally for all
> engines as discussed in the bug report, that would be ok. It's nothing I
> can take on myself.

LuaTeX already exposes the Exif orientation data, so if we switch to the
Lua reimplementation of extractbb [1], then I could add this trivially.
The dvipdfmx manual says that it can parse the resolution from the Exif
data, so it probably wouldn't be _too_ hard to add support to the
current C implementation of extractbb, although I don't have much
interest in doing so.

Either way, this would only expose the orientation data, not actually
rotate the images itself.

> Unfortunately, for compatibility I think such patches would have to
> include a new primitive to specify whether the exif rotation should be
> applied. Otherwise, existing documents and workflows would suddenly
> give different results when rerun on the same image files. That sounds
> like a nightmare to me.

Agreed. To make this extractbb method work automatically with LaTeX +
{pdf,Xe,up,Lua}TeX, someone would need to add a package option to
graphicx that forces it to run extractbb on every image, then apply the
extracted rotation to each image. The xdvipdfmx driver already does this
for the dimensions of every image, so we could mostly just copy that
code. We'd only need this 1 code path for all 4 engines, so this
shouldn't be _too_ much work to implement.

The downside to this strategy is that it would slow down compilation a
little bit since it would have to call extractbb for every image. XeTeX
and upTeX already call extractbb for some/every image, so this makes no
difference there, and for LuaTeX it would be pretty easy to implement
the whole thing in Lua, so this would only really be a problem for
pdfTeX. But I doubt that anyone wants to write an Exif parser in WEB, so
this is the best that you're probably going to get there.

Thanks,
-- Max

[1]: https://tug.org/pipermail/dvipdfmx/2024-July/000346.html



More information about the tex-live mailing list.