diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2021-12-29 15:00:59 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2021-12-29 15:00:59 +0200 |
commit | b4361712899fd0183fea5513180cb383979616de (patch) | |
tree | 688ab7ee2ab3a8cd32b4e37b506099aec95388f7 /src/Text/Pandoc/Image.hs | |
parent | 726ad97faebe59e024d68d293e663c02bbe423c8 (diff) | |
parent | d960282b105a6469c760b4308a3b81da723b7256 (diff) | |
download | pandoc-b4361712899fd0183fea5513180cb383979616de.tar.gz |
Merge https://github.com/jgm/pandoc
Diffstat (limited to 'src/Text/Pandoc/Image.hs')
-rw-r--r-- | src/Text/Pandoc/Image.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Image.hs b/src/Text/Pandoc/Image.hs index e0c938938..cbc26c981 100644 --- a/src/Text/Pandoc/Image.hs +++ b/src/Text/Pandoc/Image.hs @@ -11,24 +11,25 @@ Portability : portable Functions for converting images. -} module Text.Pandoc.Image ( svgToPng ) where -import Text.Pandoc.Options (WriterOptions(..)) import Text.Pandoc.Process (pipeProcess) import qualified Data.ByteString.Lazy as L import System.Exit import Data.Text (Text) import Text.Pandoc.Shared (tshow) import qualified Control.Exception as E +import Control.Monad.IO.Class (MonadIO(liftIO)) -- | Convert svg image to png. rsvg-convert -- is used and must be available on the path. -svgToPng :: WriterOptions +svgToPng :: MonadIO m + => Int -- ^ DPI -> L.ByteString -- ^ Input image as bytestring - -> IO (Either Text L.ByteString) -svgToPng opts bs = do - let dpi = show $ writerDpi opts - E.catch + -> m (Either Text L.ByteString) +svgToPng dpi bs = do + let dpi' = show dpi + liftIO $ E.catch (do (exit, out) <- pipeProcess Nothing "rsvg-convert" - ["-f","png","-a","--dpi-x",dpi,"--dpi-y",dpi] + ["-f","png","-a","--dpi-x",dpi',"--dpi-y",dpi'] bs return $ if exit == ExitSuccess then Right out |