@@ -182,15 +182,16 @@ findJfifSize bs = do
182182 Nothing -> fail "Did not find length record"
183183
184184exifSize :: ByteString -> Maybe ImageSize
185−exifSize = runGet (Just <$> exifHeader) . BL.fromChunks . (:[])
185+exifSize bs = runGet (Just <$> exifHeader bl) bl
186+ where bl = BL.fromChunks [bs]
186187-- NOTE: It would be nicer to do
187188-- runGet ((Just <$> exifHeader) <|> return Nothing)
188189-- which would prevent pandoc from raising an error when an exif header can't
189190-- be parsed. But we only get an Alternative instance for Get in binary 0.6,
190191-- and binary 0.5 ships with ghc 7.6.
191192
192−exifHeader :: Get ImageSize
193−exifHeader = do
193+exifHeader :: BL.ByteString -> Get ImageSize
194+exifHeader hdr = do
194195 _app1DataSize <- getWord16be
195196 exifHdr <- getWord32be
196197 unless (exifHdr == 0x45786966) $ fail "Did not find exif header"
@@ -198,7 +199,7 @@ exifHeader = do
198199 unless (zeros == 0) $ fail "Expected zeros after exif header"
199200 -- beginning of tiff header -- we read whole thing to use
200201 -- in getting data from offsets:
201− tiffHeader <- lookAhead getRemainingLazyByteString
202+ let tiffHeader = BL.drop 8 hdr
202203 byteAlign <- getWord16be
203204 let bigEndian = byteAlign == 0x4d4d
204205 let (getWord16, getWord32, getWord64) =