From 2eadc7805392c165f7286bd9a337b310b41c897d Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Fri, 20 Jun 2014 10:58:26 -0700
Subject: [PATCH] ImageSize:  Use default instead of failing if image size not
 found

in exif header.  Closes #1358.
---
 src/Text/Pandoc/ImageSize.hs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index 9e6b457c0..68b34dcf3 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -76,6 +76,9 @@ imageSize img = do
        Eps  -> epsSize img
        Pdf  -> Nothing  -- TODO
 
+defaultSize :: (Integer, Integer)
+defaultSize = (72, 72)
+
 sizeInPixels :: ImageSize -> (Integer, Integer)
 sizeInPixels s = (pxX s, pxY s)
 
@@ -260,7 +263,9 @@ exifHeader hdr = do
                            lookup ExifImageHeight allentries) of
                           (Just (UnsignedLong w), Just (UnsignedLong h)) ->
                             return (fromIntegral w, fromIntegral h)
-                          _ -> fail "Could not determine image width, height"
+                          _ -> return defaultSize
+                               -- we return a default width and height when
+                               -- the exif header doesn't contain these
   let resfactor = case lookup ResolutionUnit allentries of
                         Just (UnsignedShort 1) -> (100 / 254)
                         _ -> 1