From a778b98124de5957c1a9b68d980160d2034d5549 Mon Sep 17 00:00:00 2001 From: Evan Silberman Date: Thu, 14 Nov 2024 12:17:11 -0800 Subject: [PATCH] Flip and rotate images in Office output Transforms images based on exif metadata --- src/Text/Pandoc/Writers/Docx/OpenXML.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/Docx/OpenXML.hs b/src/Text/Pandoc/Writers/Docx/OpenXML.hs index bbd7d730eaf5..cd67927ecbb6 100644 --- a/src/Text/Pandoc/Writers/Docx/OpenXML.hs +++ b/src/Text/Pandoc/Writers/Docx/OpenXML.hs @@ -962,7 +962,17 @@ inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do , mknode "a:stretch" [] $ mknode "a:fillRect" [] () ] - xfrm = mknode "a:xfrm" [] + transform = either (const def) id $ imageTransform img + attrflip NoFlip = [] + attrflip FlipH = [("flipH", "1")] + attrflip FlipV = [("flipV", "1")] + -- 60,000ths of a degree + rotate R0 = [] + rotate R90 = [("rot", "5400000")] + rotate R180 = [("rot", "10800000")] + rotate R270 = [("rot", "16200000")] + + xfrm = mknode "a:xfrm" ((attrflip (tFlip transform)) <> (rotate (tRotate transform))) [ mknode "a:off" [("x","0"),("y","0")] () , mknode "a:ext" [("cx",tshow xemu) ,("cy",tshow yemu)] () ]