aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/ImageSize.hs11
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs2
-rw-r--r--src/Text/Pandoc/Writers/ICML.hs2
-rw-r--r--src/Text/Pandoc/Writers/ODT.hs2
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs2
5 files changed, 9 insertions, 10 deletions
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index 1c5488542..b698535ce 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -115,13 +115,13 @@ imageType img = case B.take 4 img of
-- B.groupBy openingTag matches first "<svg" or "<html" but not "<!--"
openingTag x y = x == '<' && y /= '!'
-imageSize :: ByteString -> Either String ImageSize
-imageSize img =
+imageSize :: WriterOptions -> ByteString -> Either String ImageSize
+imageSize opts img =
case imageType img of
Just Png -> mbToEither "could not determine PNG size" $ pngSize img
Just Gif -> mbToEither "could not determine GIF size" $ gifSize img
Just Jpeg -> jpegSize img
- Just Svg -> mbToEither "could not determine SVG size" $ svgSize img
+ Just Svg -> mbToEither "could not determine SVG size" $ svgSize opts img
Just Eps -> mbToEither "could not determine EPS size" $ epsSize img
Just Pdf -> Left "could not determine PDF size" -- TODO
Nothing -> Left "could not determine image type"
@@ -286,10 +286,9 @@ gifSize img = do
}
_ -> Nothing -- "GIF parse error"
-svgSize :: ByteString -> Maybe ImageSize
-svgSize img = do
+svgSize :: WriterOptions -> ByteString -> Maybe ImageSize
+svgSize opts img = do
doc <- Xml.parseXMLDoc $ UTF8.toString img
- let opts = def --TODO: use proper opts instead of def, which simply contains dpi=72
let dpi = fromIntegral $ writerDpi opts
let dirToInt dir = do
dim <- Xml.findAttrBy (== Xml.QName dir Nothing Nothing) doc >>= lengthToDim
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index f06efad23..1c19c9fa6 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -1184,7 +1184,7 @@ inlineToOpenXML' opts (Image attr alt (src, title)) = do
Right (img, mt) -> do
ident <- ("rId"++) `fmap` ((lift . lift) getUniqueId)
let (xpt,ypt) = desiredSizeInPoints opts attr
- (either (const def) id (imageSize img))
+ (either (const def) id (imageSize opts img))
-- 12700 emu = 1 pt
let (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700) (pageWidth * 12700)
let cNvPicPr = mknode "pic:cNvPicPr" [] $
diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs
index efec17d26..3b7d3c4da 100644
--- a/src/Text/Pandoc/Writers/ICML.hs
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -546,7 +546,7 @@ imageICML opts style attr (src, _) = do
report $ CouldNotFetchResource src ""
return def
Right (img, _) -> do
- case imageSize img of
+ case imageSize opts img of
Right size -> return size
Left msg -> do
report $ CouldNotDetermineImageSize src msg
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
index ee5fa4c24..61bb63d9b 100644
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -153,7 +153,7 @@ transformPicMath opts (Image attr@(id', cls, _) lab (src,t)) = do
report $ CouldNotFetchResource src ""
return $ Emph lab
Right (img, mbMimeType) -> do
- (ptX, ptY) <- case imageSize img of
+ (ptX, ptY) <- case imageSize opts img of
Right s -> return $ sizeInPoints s
Left msg -> do
report $ CouldNotDetermineImageSize src msg
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index ef012e58e..5172a0ddd 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -63,7 +63,7 @@ rtfEmbedImage opts x@(Image attr _ (src,_)) = do
"image/jpeg" -> return "\\jpegblip"
"image/png" -> return "\\pngblip"
_ -> throwError $ PandocSomeError "Unknown file type"
- sizeSpec <- case imageSize imgdata of
+ sizeSpec <- case imageSize opts imgdata of
Left msg -> do
report $ CouldNotDetermineImageSize src msg
return ""