Overview

Package gif implements a GIF image decoder and encoder.

The GIF specification is at .

Index

writer.go

Disposal Methods.

func

  1. func Decode(r .Reader) (.Image, )

Decode reads a GIF image from r and returns the first embedded image as an
image.Image.

func DecodeConfig

DecodeConfig returns the global color model and dimensions of a GIF image
without decoding the entire image.

  1. func Encode(w io., m image., o *Options)

Encode writes the Image m to w in GIF format.

func EncodeAll

EncodeAll writes the images in g to w in GIF format with the given loop count
and delay between frames.

type GIF

  1. type GIF struct {
  2. Image []*image. // The successive images.
  3. LoopCount int // The loop count.
  4. // Disposal is the successive disposal methods, one per frame. For
  5. // backwards compatibility, a nil Disposal is valid to pass to EncodeAll,
  6. // and implies that each frame's disposal method is 0 (no disposal
  7. // specified).
  8. Disposal []
  9. // Config is the global color table (palette), width and height. A nil or
  10. // empty-color.Palette Config.ColorModel means that each frame has its own
  11. // color table and there is no global color table. Each frame's bounds must
  12. // be within the rectangle defined by the two points (0, 0) and
  13. // (Config.Width, Config.Height).
  14. //
  15. // For backwards compatibility, a zero-valued Config is valid to pass to
  16. // EncodeAll, and implies that the overall GIF's width and height equals
  17. // the first frame's bounds' Rectangle.Max point.
  18. // BackgroundIndex is the background index in the global color table, for
  19. // use with the DisposalBackground disposal method.
  20. BackgroundIndex byte
  21. }

GIF represents the possibly multiple images stored in a GIF file.

func

DecodeAll reads a GIF image from r and returns the sequential frames and timing
information.

  1. type Options struct {
  2. // NumColors is the maximum number of colors used in the image.
  3. // It ranges from 1 to 256.
  4. NumColors
  5.  
  6. // Quantizer is used to produce a palette with size NumColors.
  7. // palette.Plan9 is used in place of a nil Quantizer.
  8. Quantizer draw.
  9.  
  10. // Drawer is used to convert the source image to the desired palette.
  11. // draw.FloydSteinberg is used in place of a nil Drawer.
  12. }

Options are the encoding parameters.