Avoid non-exhaustive pattern match.

This commit is contained in:
John MacFarlane 2018-08-10 15:17:49 -07:00
parent 7bc879268c
commit 0ae79275a9

View file

@ -410,9 +410,9 @@ 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
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
@ -420,10 +420,11 @@ jfifSize rest =
dpiy = factor (shift dpiy1 8 + dpiy2)
in case findJfifSize rest of
Left msg -> Left msg
Right (w,h) ->Right ImageSize { pxX = w
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 =