git.iko.soy/typeable/pandoc
on master help sign in
ImageSize: Add Tiff constructor for ImageType.

[Minor API change] This allows pandoc to get size information from tiff images. Closes #7405.

commit4a7a0cff294c48d1acd690ea593f4ab2c817ec27 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 23 Jun 2021, 11:39 (5 years ago) parent235cdea
3 files changed+7−1
src/Text/Pandoc/ImageSize.hs+5−1 src/Text/Pandoc/Writers/Docx.hs+1 src/Text/Pandoc/Writers/Powerpoint/Output.hs+1
src/Text/Pandoc/ImageSize.hs+5−1
@@ -57,7 +57,8 @@ import Codec.Picture (decodeImageWithMetadata)
5757-- quick and dirty functions to get image sizes
5858-- algorithms borrowed from wwwis.pl
5959
60−data ImageType = Png | Gif | Jpeg | Svg | Pdf | Eps | Emf deriving Show
60+data ImageType = Png | Gif | Jpeg | Svg | Pdf | Eps | Emf | Tiff
61+ deriving Show
6162data Direction = Width | Height
6263instance Show Direction where
6364 show Width = "width"
@@ -100,6 +101,8 @@ imageType :: ByteString -> Maybe ImageType
100101imageType img = case B.take 4 img of
101102 "\x89\x50\x4e\x47" -> return Png
102103 "\x47\x49\x46\x38" -> return Gif
104+ "\x49\x49\x2a\x00" -> return Tiff
105+ "\x4D\x4D\x00\x2a" -> return Tiff
103106 "\xff\xd8\xff\xe0" -> return Jpeg -- JFIF
104107 "\xff\xd8\xff\xe1" -> return Jpeg -- Exif
105108 "%PDF" -> return Pdf
@@ -124,6 +127,7 @@ imageSize opts img = checkDpi <$>
124127 Just Png -> getSize img
125128 Just Gif -> getSize img
126129 Just Jpeg -> getSize img
130+ Just Tiff -> getSize img
127131 Just Svg -> mbToEither "could not determine SVG size" $ svgSize opts img
128132 Just Eps -> mbToEither "could not determine EPS size" $ epsSize img
129133 Just Pdf -> mbToEither "could not determine PDF size" $ pdfSize img
src/Text/Pandoc/Writers/Docx.hs+1
@@ -1289,6 +1289,7 @@ inlineToOpenXML' opts (Image attr@(imgident, _, _) alt (src, title)) = do
12891289 Just Eps -> ".eps"
12901290 Just Svg -> ".svg"
12911291 Just Emf -> ".emf"
1292+ Just Tiff -> ".tiff"
12921293 Nothing -> ""
12931294 imgpath = "media/" <> ident <> imgext
12941295 mbMimeType = mt <|> getMimeType (T.unpack imgpath)
src/Text/Pandoc/Writers/Powerpoint/Output.hs+1
@@ -537,6 +537,7 @@ registerMedia fp caption = do
537537 Just Eps -> Just ".eps"
538538 Just Svg -> Just ".svg"
539539 Just Emf -> Just ".emf"
540+ Just Tiff -> Just ".tiff"
540541 Nothing -> Nothing
541542
542543 let newGlobalId = fromMaybe (maxGlobalId + 1) (M.lookup fp globalIds)