Commit 69db704d authored by Christoph Ruegge's avatar Christoph Ruegge

Read binary files as ByteString

parent 807f8c97
...@@ -37,7 +37,7 @@ chartData renderable format = do ...@@ -37,7 +37,7 @@ chartData renderable format = do
mkFile opts filename renderable mkFile opts filename renderable
-- Convert to base64. -- Convert to base64.
imgData <- fmap Char.pack $ readFile filename imgData <- Char.readFile filename
return $ return $
case format of case format of
PNG -> png width height $ base64 imgData PNG -> png width height $ base64 imgData
......
...@@ -60,8 +60,8 @@ displayImageAsJpg renderable = do ...@@ -60,8 +60,8 @@ displayImageAsJpg renderable = do
-- Write the image -- Write the image
saveJpgImage 95 filename renderable saveJpgImage 95 filename renderable
-- Convert to base64. -- Convert to base64.
imgData <- readFile filename imgData <- CBS.readFile filename
return $ Display [jpg (imWidth renderable) (imHeight renderable) $ base64 (CBS.pack imgData)] return $ Display [jpg (imWidth renderable) (imHeight renderable) $ base64 imgData]
-- The type DynamicImage does not have a function to extract width and height -- The type DynamicImage does not have a function to extract width and height
imWidth :: DynamicImage -> Int imWidth :: DynamicImage -> Int
......
...@@ -28,7 +28,7 @@ figureData figure format = do ...@@ -28,7 +28,7 @@ figureData figure format = do
writeFigure format fname (w, h) figure writeFigure format fname (w, h) figure
-- Read back, and convert to base64. -- Read back, and convert to base64.
imgData <- Char.pack <$> readFile fname imgData <- Char.readFile fname
let value = let value =
case format of case format of
PNG -> png w h $ base64 imgData PNG -> png w h $ base64 imgData
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment