~ubuntu-branches/ubuntu/saucy/pandoc/saucy

« back to all changes in this revision

Viewing changes to src/Text/Pandoc/ImageSize.hs

  • Committer: Package Import Robot
  • Author(s): Joachim Breitner
  • Date: 2013-05-25 00:41:12 UTC
  • mfrom: (3.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20130525004112-7kun3p25zx2hibxs
Tags: 1.11.1-2
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
-- quick and dirty functions to get image sizes
39
39
-- algorithms borrowed from wwwis.pl
40
40
 
41
 
data ImageType = Png | Gif | Jpeg deriving Show
 
41
data ImageType = Png | Gif | Jpeg | Pdf deriving Show
42
42
 
43
43
data ImageSize = ImageSize{
44
44
                     pxX   :: Integer
53
53
                     "\x89\x50\x4e\x47" -> return Png
54
54
                     "\x47\x49\x46\x38" -> return Gif
55
55
                     "\xff\xd8\xff\xe0" -> return Jpeg
 
56
                     "%PDF"             -> return Pdf
56
57
                     _                  -> fail "Unknown image type"
57
58
 
58
59
imageSize :: ByteString -> Maybe ImageSize
62
63
       Png  -> pngSize img
63
64
       Gif  -> gifSize img
64
65
       Jpeg -> jpegSize img
 
66
       Pdf  -> Nothing  -- TODO
65
67
 
66
68
sizeInPixels :: ImageSize -> (Integer, Integer)
67
69
sizeInPixels s = (pxX s, pxY s)