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

Safe HaskellNone
LanguageHaskell2010

Codec.Picture.Png

Contents

Description

Module used for loading & writing 'Portable Network Graphics' (PNG) files.

A high level API is provided. It loads and saves images for you while hiding all the details about PNG chunks.

Basic functions for PNG handling are decodePng, encodePng and encodePalettedPng. Convenience functions are provided for direct file handling and using DynamicImages.

The loader has been validated against the pngsuite (http:/www.libpng.orgpubpngpngsuite.html)

Synopsis

High level functions

class PngSavable a where Source #

Encode an image into a png if possible.

Minimal complete definition

encodePngWithMetadata

Methods

encodePng :: Image a -> ByteString Source #

Transform an image into a png encoded bytestring, ready to be written as a file.

encodePngWithMetadata :: Metadatas -> Image a -> ByteString Source #

Encode a png using some metadatas. The following metadata keys will be stored in a tEXt field :

the followings metadata will bes tored in the gAMA chunk.

The followings metadata will be stored in a pHYs chunk

class PngPaletteSaveable a where Source #

Encode a paletted image into a png if possible.

Minimal complete definition

encodePalettedPngWithMetadata

Methods

encodePalettedPng :: Image a -> Image Pixel8 -> Either String ByteString Source #

Encode a paletted image as a color indexed 8-bit PNG. the palette must have between 1 and 256 values in it. Accepts PixelRGB8 and PixelRGBA8 as palette pixel type

encodePalettedPngWithMetadata :: Metadatas -> Image a -> Image Pixel8 -> Either String ByteString Source #

Equivalent to encodePalettedPng but allow writing of metadatas. See encodePngWithMetadata for the details of encoded metadatas Accepts PixelRGB8 and PixelRGBA8 as palette pixel type

decodePng :: ByteString -> Either String DynamicImage Source #

Transform a raw png image to an image, without modifying the underlying pixel type. If the image is greyscale and < 8 bits, a transformation to RGBA8 is performed. This should change in the future. The resulting image let you manage the pixel types.

This function can output the following images:

decodePngWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas) Source #

Decode a PNG file with, possibly, separated palette.

decodePngWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas) Source #

Same as decodePng but also extract meta datas present in the files.

writePng :: PngSavable pixel => FilePath -> Image pixel -> IO () Source #

Helper function to directly write an image as a png on disk.

encodePalettedPng :: PngPaletteSaveable a => Image a -> Image Pixel8 -> Either String ByteString Source #

Encode a paletted image as a color indexed 8-bit PNG. the palette must have between 1 and 256 values in it. Accepts PixelRGB8 and PixelRGBA8 as palette pixel type

encodePalettedPngWithMetadata :: PngPaletteSaveable a => Metadatas -> Image a -> Image Pixel8 -> Either String ByteString Source #

Equivalent to encodePalettedPng but allow writing of metadatas. See encodePngWithMetadata for the details of encoded metadatas Accepts PixelRGB8 and PixelRGBA8 as palette pixel type

writeDynamicPng :: FilePath -> DynamicImage -> IO (Either String Bool) Source #

Write a dynamic image in a .png image file if possible. The same restriction as encodeDynamicPng apply.