Respect Exif orientation in LaTeX, Docx, ODT output #10386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch uses EXIF orientation metadata in image files to affect the output of images in Docx, ODT, and LaTeX writers. Addresses #10311 for these three writers only.
Having worked on this for a few days I am a bit dubious that this in scope for Pandoc. On the one hand, it's probably somewhat common for users to encounter images with a flipped/rotated orientation, given the behavior smartphone cameras and so on, and common to not know what's going on or how to fix it when you generate a PDF with Pandoc. On the other hand, the problem has to be addressed in a specific way for each output format and the results can questionable.
The LaTeX case is particularly bad here, I think. For one thing, it introduces a need to read the image bytes in the LaTeX writer where it was previously unnecessary, and so I'm just ignoring all
fetchItem
exceptions and defaulting to no rotation. There's also no necessary relationship between the environment wherepandoc
is being run and the environment where LaTeX is being run: if someone has a rotatedfoo.jpg
in their working directory when they run pandoc, then they execute LaTeX in a directory with an unrotatedfoo.jpg
, have we done the right thing or not?In the ODT case, there's no good-looking solution available without actually rotating the pixels of the image data. See the commit message for cc73c01.
I think the approach here is more or less reasonable but I don't wholeheartedly endorse it.
Incidentally, typst natively respects EXIF orientation, seemingly by actually rotating and flipping the pixels, see here