diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-06-20 10:58:26 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-06-20 10:58:26 -0700 |
commit | 2eadc7805392c165f7286bd9a337b310b41c897d (patch) | |
tree | 76e42bf831f96692284d51ae2990a34a233cf76f /src | |
parent | b3b40546cb5ad00ee6fadcd83bcc38854fb137ae (diff) | |
download | pandoc-2eadc7805392c165f7286bd9a337b310b41c897d.tar.gz |
ImageSize: Use default instead of failing if image size not found
in exif header. Closes #1358.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/ImageSize.hs | 7 |
1 files changed, 6 insertions, 1 deletions
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 |