Skip to content

Commit

Permalink
Flip and rotate images in Office output
Browse files Browse the repository at this point in the history
Transforms images based on exif metadata
  • Loading branch information
silby committed Nov 14, 2024
1 parent 7e19347 commit a778b98
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Text/Pandoc/Writers/Docx/OpenXML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)] () ]
Expand Down

0 comments on commit a778b98

Please sign in to comment.