Skip to content

Commit

Permalink
log(svgToPng): log calls to rsvg-convert with --trace
Browse files Browse the repository at this point in the history
Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Dec 26, 2023
1 parent 3c17869 commit 6237700
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Text/Pandoc/Image.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ import Data.Text (Text)
import Text.Pandoc.Shared (tshow)
import qualified Control.Exception as E
import Control.Monad.IO.Class (MonadIO(liftIO))
import Text.Pandoc.Class.PandocMonad
import qualified Data.Text as T

-- | Convert svg image to png. rsvg-convert
-- is used and must be available on the path.
svgToPng :: MonadIO m
svgToPng :: (PandocMonad m, MonadIO m)
=> Int -- ^ DPI
-> L.ByteString -- ^ Input image as bytestring
-> m (Either Text L.ByteString)
svgToPng dpi bs = do
let dpi' = show dpi
let args = ["-f","png","-a","--dpi-x",dpi',"--dpi-y",dpi']
trace (T.intercalate " " $ map T.pack $ "rsvg-convert" : args)
liftIO $ E.catch
(do (exit, out) <- pipeProcess Nothing "rsvg-convert"
["-f","png","-a","--dpi-x",dpi',"--dpi-y",dpi']
args
bs
return $ if exit == ExitSuccess
then Right out
Expand Down

0 comments on commit 6237700

Please sign in to comment.