aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-08-27 22:27:01 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-08-27 22:27:01 -0700
commit4d7cdc467163601fd819199a69860616a9778040 (patch)
treecf346d0240e1161dedab0e1e571456d9bda8f7c8
parenteb7ed27f3f30ef954fe22c8b194f39f8ac8d0029 (diff)
downloadpandoc-4d7cdc467163601fd819199a69860616a9778040.tar.gz
Image: Generalize svgToPng to MonadIO.
-rw-r--r--src/Text/Pandoc/Image.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Image.hs b/src/Text/Pandoc/Image.hs
index 468edf2c2..cbc26c981 100644
--- a/src/Text/Pandoc/Image.hs
+++ b/src/Text/Pandoc/Image.hs
@@ -11,22 +11,23 @@ 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 :: Int -- ^ DPI
+svgToPng :: MonadIO m
+ => Int -- ^ DPI
-> L.ByteString -- ^ Input image as bytestring
- -> IO (Either Text L.ByteString)
+ -> m (Either Text L.ByteString)
svgToPng dpi bs = do
let dpi' = show dpi
- E.catch
+ liftIO $ E.catch
(do (exit, out) <- pipeProcess Nothing "rsvg-convert"
["-f","png","-a","--dpi-x",dpi',"--dpi-y",dpi']
bs