aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-08-10 15:17:49 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-08-10 15:17:49 -0700
commit0ae79275a980e158c3ac93df79ed33329150b7e0 (patch)
tree433fe293bdb5b847a635429abd2e78797dda06af /src/Text/Pandoc
parent7bc879268c1a86799a642280c296011e07e98c77 (diff)
downloadpandoc-0ae79275a980e158c3ac93df79ed33329150b7e0.tar.gz
Avoid non-exhaustive pattern match.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/ImageSize.hs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index 00ab86eab..43d4877a0 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -410,20 +410,21 @@ jpegSize img =
jfifSize :: ByteString -> Either String ImageSize
jfifSize rest =
- let [dpiDensity,dpix1,dpix2,dpiy1,dpiy2] = map fromIntegral
- $ unpack $ B.take 5 $B.drop 9 rest
- factor = case dpiDensity of
- 1 -> id
- 2 -> \x -> x * 254 `div` 10
- _ -> const 72
- dpix = factor (shift dpix1 8 + dpix2)
- dpiy = factor (shift dpiy1 8 + dpiy2)
- in case findJfifSize rest of
- Left msg -> Left msg
- Right (w,h) ->Right ImageSize { pxX = w
+ case map fromIntegral $ unpack $ B.take 5 $ B.drop 9 rest of
+ [dpiDensity,dpix1,dpix2,dpiy1,dpiy2] ->
+ let factor = case dpiDensity of
+ 1 -> id
+ 2 -> \x -> x * 254 `div` 10
+ _ -> const 72
+ dpix = factor (shift dpix1 8 + dpix2)
+ dpiy = factor (shift dpiy1 8 + dpiy2)
+ in case findJfifSize rest of
+ Left msg -> Left msg
+ Right (w,h) -> Right ImageSize { pxX = w
, pxY = h
, dpiX = dpix
, dpiY = dpiy }
+ _ -> Left "unable to determine JFIF size"
findJfifSize :: ByteString -> Either String (Integer,Integer)
findJfifSize bs =