Copyright | Copyright (C) 2011-2022 John MacFarlane |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Stability | alpha |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Text.Pandoc.ImageSize
Description
Functions for determining the size of a PNG, JPEG, or GIF image.
Synopsis
- data ImageType
- imageType :: ByteString -> Maybe ImageType
- imageSize :: WriterOptions -> ByteString -> Either Text ImageSize
- sizeInPixels :: ImageSize -> (Integer, Integer)
- sizeInPoints :: ImageSize -> (Double, Double)
- desiredSizeInPoints :: WriterOptions -> Attr -> ImageSize -> (Double, Double)
- data Dimension
- data Direction
- dimension :: Direction -> Attr -> Maybe Dimension
- lengthToDim :: Text -> Maybe Dimension
- scaleDimension :: Double -> Dimension -> Dimension
- inInch :: WriterOptions -> Dimension -> Double
- inPixel :: WriterOptions -> Dimension -> Integer
- inPoints :: WriterOptions -> Dimension -> Double
- inEm :: WriterOptions -> Dimension -> Double
- numUnit :: Text -> Maybe (Double, Text)
- showInInch :: WriterOptions -> Dimension -> Text
- showInPixel :: WriterOptions -> Dimension -> Text
- showFl :: RealFloat a => a -> Text
Documentation
imageType :: ByteString -> Maybe ImageType #
imageSize :: WriterOptions -> ByteString -> Either Text ImageSize #
sizeInPixels :: ImageSize -> (Integer, Integer) #
sizeInPoints :: ImageSize -> (Double, Double) #
Calculate (height, width) in points using the image file's dpi metadata, using 72 Points == 1 Inch.
desiredSizeInPoints :: WriterOptions -> Attr -> ImageSize -> (Double, Double) #
Calculate (height, width) in points, considering the desired dimensions in the attribute, while falling back on the image file's dpi metadata if no dimensions are specified in the attribute (or only dimensions in percentages).
Instances
dimension :: Direction -> Attr -> Maybe Dimension #
Read a Dimension from an Attr attribute. `dimension Width attr` might return `Just (Pixel 3)` or for example `Just (Centimeter 2.0)`, etc.
lengthToDim :: Text -> Maybe Dimension #
scaleDimension :: Double -> Dimension -> Dimension #
Scale a dimension by a factor.
inInch :: WriterOptions -> Dimension -> Double #
inPixel :: WriterOptions -> Dimension -> Integer #
inPoints :: WriterOptions -> Dimension -> Double #
inEm :: WriterOptions -> Dimension -> Double #
numUnit :: Text -> Maybe (Double, Text) #
Maybe split a string into a leading number and trailing unit, e.g. "3cm" to Just (3.0, "cm")
showInInch :: WriterOptions -> Dimension -> Text #
Convert a Dimension to Text denoting its equivalent in inches, for example "2.00000". Note: Dimensions in percentages are converted to the empty string.
showInPixel :: WriterOptions -> Dimension -> Text #
Convert a Dimension to Text denoting its equivalent in pixels, for example "600". Note: Dimensions in percentages are converted to the empty string.