JuicyPixels-3.2.6.4: Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance)

Safe Haskell | None
Language | Haskell2010

Codec.Picture.Metadata

Contents

- Types
- Functions
- Folding
- Helper functions
- Conversion functions

Description

This module expose a common "metadata" storage for various image type. Different format can generate different metadatas, and write only a part of them.

Since version 3.2.5

Synopsis

- data Metadatas
- data Keys a where
  - Gamma :: Keys Double
  - Format :: Keys SourceFormat
  - DpiX :: Keys Word
  - DpiY :: Keys Word
  - Width :: Keys Word
  - Height :: Keys Word
  - Title :: Keys String
  - Description :: Keys String
  - Author :: Keys String
  - Copyright :: Keys String
  - Software :: Keys String
  - Comment :: Keys String
  - Disclaimer :: Keys String
  - Source :: Keys String
  - Warning :: Keys String
  - Exif :: !ExifTag -> Keys ExifData
  - Unknown :: !String -> Keys Value
- data Value
  - = Int !Int
  - | Double !Double
  - | String !String
- data Elem k = forall a . (Show a, NFData a) => !(k a) :=> a
- data SourceFormat
  - = SourceJpeg
  - | SourceGif
  - | SourceBitmap
  - | SourceTiff
  - | SourcePng
  - | SourceHDR
  - | SourceTGA
- lookup :: Keys a -> Metadatas -> Maybe a
- empty :: Metadatas
- insert :: (Show a, NFData a) => Keys a -> a -> Metadatas -> Metadatas
- delete :: Keys a -> Metadatas -> Metadatas
- singleton :: (Show a, NFData a) => Keys a -> a -> Metadatas
- foldl' :: (acc -> Elem Keys -> acc) -> acc -> Metadatas -> acc
- foldMap :: Monoid m => (Elem Keys -> m) -> Metadatas -> m
- mkDpiMetadata :: Word -> Metadatas
- mkSizeMetadata :: Integral n => n -> n -> Metadatas
- basicMetadata :: Integral nSize => SourceFormat -> nSize -> nSize -> Metadatas
- simpleMetadata :: (Integral nSize, Integral nDpi) => SourceFormat -> nSize -> nSize -> nDpi -> nDpi -> Metadatas
- dotsPerMeterToDotPerInch :: Word -> Word
- dotPerInchToDotsPerMeter :: Word -> Word
- dotsPerCentiMeterToDotPerInch :: Word -> Word

# Types

data Metadatas Source

Dependent storage used for metadatas. All metadatas of a given kind are unique within this container.

The current data structure is based on list, so bad performances can be expected.

Instances

Show Metadatas Source |
Monoid Metadatas Source |
NFData Metadatas Source |

data Keys a where Source

Store various additional information about an image. If something is not recognized, it can be stored in an unknown tag.

- `DpiX` Dot per inch on this x axis.
- `DpiY` Dot per inch on this y axis.
- `Width` Image width in pixel. Relying on the metadata for this information can avoid the full decompression of the image. Ignored for image writing.
- `Height` Image height in pixels. Relyiung on the metadata for this information can void the full decomrpession of the image. Ignored for image writing.
- `Unknown` unlikely to be decoded, but usefull for metadata writing
- `Exif` Exif tag and associated data.

Constructors

Gamma :: Keys Double |
Format :: Keys SourceFormat |
DpiX :: Keys Word |
DpiY :: Keys Word |
Width :: Keys Word |
Height :: Keys Word |
Title :: Keys String |
Description :: Keys String |
Author :: Keys String |
Copyright :: Keys String |
Software :: Keys String |
Comment :: Keys String |
Disclaimer :: Keys String |
Source :: Keys String |
Warning :: Keys String |
Exif :: !ExifTag -> Keys ExifData |
Unknown :: !String -> Keys Value |

Instances

Eq (Keys a) Source |
Show (Elem Keys) Source |
Show (Keys a) Source |
NFData (Elem Keys) Source |

data Value Source

Encode values for unknown information

Constructors

Int !Int |
Double !Double |
String !String |

Instances

Eq Value Source |
Show Value Source |
NFData Value Source |

data Elem k Source

Element describing a metadata and it's (typed) associated value.

Constructors

forall a . (Show a, NFData a) => !(k a) :=> a |

Instances

Show (Elem Keys) Source |
NFData (Elem Keys) Source |

data SourceFormat Source

Type describing the original file format of the ilfe.

Constructors

SourceJpeg |
SourceGif |
SourceBitmap |
SourceTiff |
SourcePng |
SourceHDR |
SourceTGA |

Instances

Eq SourceFormat Source |
Show SourceFormat Source |
NFData SourceFormat Source |

# Functions

lookup :: Keys a -> Metadatas -> Maybe a Source

Search a metadata with the given key.

empty :: Metadatas Source

Empty metadatas. Favor `mempty`

insert :: (Show a, NFData a) => Keys a -> a -> Metadatas -> Metadatas Source

Insert an element in the metadatas, if an element with the same key is present, it is overwritten.

delete :: Keys a -> Metadatas -> Metadatas Source

Remove an element of the given keys from the metadatas. If not present does nothing.

singleton :: (Show a, NFData a) => Keys a -> a -> Metadatas Source

Create metadatas with a single element.

# Folding

foldl' :: (acc -> Elem Keys -> acc) -> acc -> Metadatas -> acc Source

Strict left fold of the metadatas

foldMap :: Monoid m => (Elem Keys -> m) -> Metadatas -> m Source

foldMap equivalent for metadatas.

# Helper functions

mkDpiMetadata :: Word -> Metadatas Source

Create metadatas indicating the resolution, with DpiX == DpiY

mkSizeMetadata :: Integral n => n -> n -> Metadatas Source

Create metadatas holding width and height information.

basicMetadata :: Integral nSize => SourceFormat -> nSize -> nSize -> Metadatas Source

Create simple metadatas with Format, Width & Height

simpleMetadata :: (Integral nSize, Integral nDpi) => SourceFormat -> nSize -> nSize -> nDpi -> nDpi -> Metadatas Source

Create simple metadatas with Format, Width, Height, DpiX & DpiY

# Conversion functions

dotsPerMeterToDotPerInch :: Word -> Word Source

Conversion from dpm to dpi

dotPerInchToDotsPerMeter :: Word -> Word Source

Conversion from dpi to dpm

dotsPerCentiMeterToDotPerInch :: Word -> Word Source

Conversion dpcm -> dpi