git.iko.soy/typeable/pandoc
on master help sign in
ImageSize: Added Pdf to ImageType.

So far we have no function to determine PDF's size.

commit588a49acf983909907ea438e66cd88d3b21c6c9a authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 23 Feb 2013, 23:03 (14 years ago) parentaa4105d
1 file changed+3−1
src/Text/Pandoc/ImageSize.hs+3−1
src/Text/Pandoc/ImageSize.hs+3−1
@@ -38,7 +38,7 @@ import Data.Bits
3838-- quick and dirty functions to get image sizes
3939-- algorithms borrowed from wwwis.pl
4040
41−data ImageType = Png | Gif | Jpeg deriving Show
41+data ImageType = Png | Gif | Jpeg | Pdf deriving Show
4242
4343data ImageSize = ImageSize{
4444 pxX :: Integer
@@ -53,6 +53,7 @@ imageType img = case B.take 4 img of
5353 "\x89\x50\x4e\x47" -> return Png
5454 "\x47\x49\x46\x38" -> return Gif
5555 "\xff\xd8\xff\xe0" -> return Jpeg
56+ "%PDF" -> return Pdf
5657 _ -> fail "Unknown image type"
5758
5859imageSize :: ByteString -> Maybe ImageSize
@@ -62,6 +63,7 @@ imageSize img = do
6263 Png -> pngSize img
6364 Gif -> gifSize img
6465 Jpeg -> jpegSize img
66+ Pdf -> Nothing -- TODO
6567
6668sizeInPixels :: ImageSize -> (Integer, Integer)
6769sizeInPixels s = (pxX s, pxY s)