pandoc-3.7.0.2: Conversion between markup formats

Copyright | Copyright (C) 2011-2024 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
  - = Png
  - | Gif
  - | Jpeg
  - | Svg
  - | Pdf
  - | Eps
  - | Emf
  - | Tiff
  - | Webp
- data ImageSize = ImageSize {
  - pxX :: Integer
  - pxY :: Integer
  - dpiX :: Integer
  - dpiY :: Integer
  }
- 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
  - = Pixel Integer
  - | Centimeter Double
  - | Millimeter Double
  - | Inch Double
  - | Percent Double
  - | Em Double
- data Direction
  - = Width
  - | Height
- 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

data ImageType Source #

Constructors

Png |
Gif |
Jpeg |
Svg |
Pdf |
Eps |
Emf |
Tiff |
Webp |

#### Instances

Instances details

Show ImageType Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods showsPrec :: Int -> ImageType -> ShowS Source # show :: ImageType -> String Source # showList :: [ImageType] -> ShowS Source #

data ImageSize Source #

Constructors

ImageSize |

Fields

- pxX :: Integer
- pxY :: Integer
- dpiX :: Integer
- dpiY :: Integer

#### Instances

Instances details

Default ImageSize Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods def :: ImageSize Source #
Read ImageSize Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods readsPrec :: Int -> ReadS ImageSize Source # readList :: ReadS [ImageSize] Source # readPrec :: ReadPrec ImageSize Source # readListPrec :: ReadPrec [ImageSize] Source #
Show ImageSize Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods showsPrec :: Int -> ImageSize -> ShowS Source # show :: ImageSize -> String Source # showList :: [ImageSize] -> ShowS Source #
Eq ImageSize Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods (==) :: ImageSize -> ImageSize -> Bool Source # (/=) :: ImageSize -> ImageSize -> Bool Source #

imageType :: ByteString -> Maybe ImageType Source #

imageSize :: WriterOptions -> ByteString -> Either Text ImageSize Source #

sizeInPixels :: ImageSize -> (Integer, Integer) Source #

sizeInPoints :: ImageSize -> (Double, Double) Source #

Calculate (height, width) in points using the image file's dpi metadata, using 72 Points == 1 Inch.

desiredSizeInPoints :: WriterOptions -> Attr -> ImageSize -> (Double, Double) Source #

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).

data Dimension Source #

Constructors

Pixel Integer |
Centimeter Double |
Millimeter Double |
Inch Double |
Percent Double |
Em Double |

#### Instances

Instances details

Show Dimension Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods showsPrec :: Int -> Dimension -> ShowS Source # show :: Dimension -> String Source # showList :: [Dimension] -> ShowS Source #
Eq Dimension Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods (==) :: Dimension -> Dimension -> Bool Source # (/=) :: Dimension -> Dimension -> Bool Source #

data Direction Source #

Constructors

Width |
Height |

#### Instances

Instances details

Show Direction Source # |
Instance details Defined in Text.Pandoc.ImageSize Methods showsPrec :: Int -> Direction -> ShowS Source # show :: Direction -> String Source # showList :: [Direction] -> ShowS Source #

dimension :: Direction -> Attr -> Maybe Dimension Source #

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 Source #

scaleDimension :: Double -> Dimension -> Dimension Source #

Scale a dimension by a factor.

inInch :: WriterOptions -> Dimension -> Double Source #

inPixel :: WriterOptions -> Dimension -> Integer Source #

inPoints :: WriterOptions -> Dimension -> Double Source #

inEm :: WriterOptions -> Dimension -> Double Source #

numUnit :: Text -> Maybe (Double, Text) Source #

Maybe split a string into a leading number and trailing unit, e.g. "3cm" to Just (3.0, "cm")

showInInch :: WriterOptions -> Dimension -> Text Source #

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 Source #

Convert a Dimension to Text denoting its equivalent in pixels, for example "600". Note: Dimensions in percentages are converted to the empty string.

showFl :: RealFloat a => a -> Text Source #