@@ -842,7 +842,7 @@ inlineToOpenXML opts (Image alt (src, tit)) = do
842 let size = imageSize img
842 let size = imageSize img
843 let (xpt,ypt) = maybe (120,120) sizeInPoints size
843 let (xpt,ypt) = maybe (120,120) sizeInPoints size
844 -- 12700 emu = 1 pt
844 -- 12700 emu = 1 pt
845− let (xemu,yemu) = (xpt * 12700, ypt * 12700)
845+ let (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700)
846 let cNvPicPr = mknode "pic:cNvPicPr" [] $
846 let cNvPicPr = mknode "pic:cNvPicPr" [] $
847 mknode "a:picLocks" [("noChangeArrowheads","1"),("noChangeAspect","1")] ()
847 mknode "a:picLocks" [("noChangeArrowheads","1"),("noChangeAspect","1")] ()
848 let nvPicPr = mknode "pic:nvPicPr" []
848 let nvPicPr = mknode "pic:nvPicPr" []
@@ -907,3 +907,11 @@ parseXml refArchive distArchive relpath =
907 >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
907 >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
908 Just d -> return d
908 Just d -> return d
909 Nothing -> fail $ relpath ++ " corrupt or missing in reference docx"
909 Nothing -> fail $ relpath ++ " corrupt or missing in reference docx"
911+-- | Scales the image to fit the page
912+fitToPage :: (Integer, Integer) -> (Integer, Integer)
914+ --5440680 is the emu width size of a letter page in portrait, minus the margins
916+ (5440680, round $ (5440680 / ((fromIntegral :: Integer -> Double) x)) * (fromIntegral y))
917+ | otherwise = (x, y)