@@ -70,15 +70,17 @@ imageType img = case B.take 4 img of
7070 -> return Eps
7171 _ -> (hush . Left) "Unknown image type"
7272
73−imageSize :: ByteString -> Maybe ImageSize
74−imageSize img = do
75− t <- imageType img
76− case t of
77− Png -> pngSize img
78− Gif -> gifSize img
79− Jpeg -> jpegSize img
80− Eps -> epsSize img
81− Pdf -> Nothing -- TODO
73+imageSize :: ByteString -> Either String ImageSize
74+imageSize img =
75+ case imageType img of
76+ Just Png -> mbToEither "could not determine PNG size" $ pngSize img
77+ Just Gif -> mbToEither "could not determine GIF size" $ gifSize img
78+ Just Jpeg -> mbToEither "could not determine JPEG size" $ jpegSize img
79+ Just Eps -> mbToEither "could not determine EPS size" $ epsSize img
80+ Just Pdf -> Left "could not determine PDF size" -- TODO
81+ Nothing -> Left "could not determine image type"
82+ where mbToEither msg Nothing = Left msg
83+ mbToEither _ (Just x) = Right x
8284
8385defaultSize :: (Integer, Integer)
8486defaultSize = (72, 72)