From 60bf4a8bfb543fcf8021356e6c4ad2b994acd8c8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 9 May 2015 23:56:18 -0700 Subject: Improved warnings when image size can't be determined. Closes #1834. --- src/Text/Pandoc/Writers/Docx.hs | 7 +++++-- src/Text/Pandoc/Writers/ODT.hs | 6 ++++-- src/Text/Pandoc/Writers/RTF.hs | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index cacf5102f..475f4e2ac 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -1122,8 +1122,11 @@ inlineToOpenXML opts (Image alt (src, tit)) = do ident <- ("rId"++) `fmap` getUniqueId (xpt,ypt) <- case imageSize img of Right size -> return $ sizeInPoints size - Left msg -> do liftIO (warn msg) - return (120,120) + Left msg -> do + liftIO $ warn $ + "Could not determine image size in `" ++ + src ++ "': " ++ msg + return (120,120) -- 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/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs index 33d9ec9d2..e7c1cf32e 100644 --- a/src/Text/Pandoc/Writers/ODT.hs +++ b/src/Text/Pandoc/Writers/ODT.hs @@ -136,8 +136,10 @@ transformPicMath opts entriesRef (Image lab (src,t)) = do Right (img, mbMimeType) -> do (w,h) <- case imageSize img of Right size -> return $ sizeInPoints size - Left msg -> do warn msg - return (0,0) + Left msg -> do + warn $ "Could not determine image size in `" ++ + src ++ "': " ++ msg + return (0,0) let tit' = show w ++ "x" ++ show h entries <- readIORef entriesRef let extension = fromMaybe (takeExtension $ takeWhile (/='?') src) diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs index 588506f34..9eb02ad02 100644 --- a/src/Text/Pandoc/Writers/RTF.hs +++ b/src/Text/Pandoc/Writers/RTF.hs @@ -57,7 +57,10 @@ rtfEmbedImage opts x@(Image _ (src,_)) = do "image/png" -> "\\pngblip" _ -> error "Unknown file type" sizeSpec <- case imageSize imgdata of - Left msg -> warn msg >> return "" + Left msg -> do + warn $ "Could not determine image size in `" ++ + src ++ "': " ++ msg + return "" Right sz -> return $ "\\picw" ++ show xpx ++ "\\pich" ++ show ypx ++ "\\picwgoal" ++ show (xpt * 20) -- cgit v1.2.3