version: 1.10

package gif

import "image/gif"

Overview

Package gif implements a GIF image decoder and encoder.

The GIF specification is at http://www.w3.org/Graphics/GIF/spec-gif89a.txt.

Index

Package files

reader.go writer.go

Constants

  1. const (
  2. DisposalNone = 0x01
  3. DisposalBackground = 0x02
  4. DisposalPrevious = 0x03
  5. )

Disposal Methods.

func Decode

  1. func Decode(r io.Reader) (image.Image, error)

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

func DecodeConfig

  1. func DecodeConfig(r io.Reader) (image.Config, error)

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

func Encode

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

Encode writes the Image m to w in GIF format.

func EncodeAll

  1. func EncodeAll(w io.Writer, g *GIF) error

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

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

func DecodeAll

  1. func DecodeAll(r io.Reader) (*GIF, error)

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

type Options

  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 int
  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.Quantizer
  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. Drawer draw.Drawer
  13. }

Options are the encoding parameters.