JuicyPixels-3.3.9: Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Codec.Picture.Gif

Description

Module implementing GIF decoding.

Synopsis

Reading

decodeGif :: ByteString -> Either String DynamicImage Source #

Transform a raw gif image to an image, without modifying the pixels. This function can output the following images:

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

Transform a raw gif image to an image, without modifying the pixels. This function can output the following images:

Metadatas include Width & Height information.

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

Return the gif image with metadata and palette. The palette is only returned for the first image of an animation and has no transparency.

decodeGifImages :: ByteString -> Either String [DynamicImage] Source #

Transform a raw gif to a list of images, representing all the images of an animation.

getDelaysGifImages :: ByteString -> Either String [GifDelay] Source #

Extract a list of frame delays from a raw gif.

Writing

type GifDelay = Int Source #

Delay to wait before showing the next Gif image. The delay is expressed in 100th of seconds.

data GifEncode Source #

GIF image definition for encoding

Constructors

GifEncode 

Fields

data GifFrame Source #

An individual image frame in a GIF image

Constructors

GifFrame 

Fields

data GifLooping Source #

Help to control the behaviour of GIF animation looping.

Constructors

LoopingNever

The animation will stop once the end is reached

LoopingForever

The animation will restart once the end is reached

LoopingRepeat Word16

The animation will repeat n times before stoping

encodeGifImage :: Image Pixel8 -> ByteString Source #

Encode a greyscale image to a bytestring.

encodeGifImageWithPalette :: Image Pixel8 -> Palette -> Either String ByteString Source #

Encode an image with a given palette. Can return errors if the palette is ill-formed.

  • A palette must have between 1 and 256 colors

encodeGifImages :: GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String ByteString Source #

Encode a gif animation to a bytestring.

  • Every image must have the same size
  • Every palette must have between one and 256 colors.

encodeComplexGifImage :: GifEncode -> Either String ByteString Source #

Encode a complex gif to a bytestring.

  • There must be at least one image.
  • The screen and every frame dimensions must be between 1 and 65535.
  • Every frame image must fit within the screen bounds.
  • Every palette must have between one and 256 colors.
  • There must be a global palette or every image must have a local palette.
  • The background color index must be present in the global palette.
  • Every frame's transparent color index, if set, must be present in the palette used by that frame.
  • Every color index used in an image must be present in the palette used by that frame.

writeGifImage :: FilePath -> Image Pixel8 -> IO () Source #

Write a greyscale in a gif file on the disk.

writeGifImageWithPalette :: FilePath -> Image Pixel8 -> Palette -> Either String (IO ()) Source #

Write a gif image with a palette to a file.

  • A palette must have between 1 and 256 colors

writeGifImages :: FilePath -> GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String (IO ()) Source #

Write a list of images as a gif animation in a file.

  • Every image must have the same size
  • Every palette must have between one and 256 colors.

greyPalette :: Palette Source #

Default palette to produce greyscale images.