package gif

Import Path
	image/gif (on go.dev)

Dependency Relation
	imports 12 packages, and imported by 4 packages

Involved Source Files Package gif implements a GIF image decoder and encoder. The GIF specification is at https://www.w3.org/Graphics/GIF/spec-gif89a.txt. When decoding untrusted input, read dimensions with [DecodeConfig] before calling [Decode] or [DecodeAll]; see those functions and the "Security Considerations" section in the [image] package documentation. writer.go
Package-Level Type Names (total 2)
/* sort by: | */
GIF represents the possibly multiple images stored in a GIF file. BackgroundIndex is the background index in the global color table, for use with the DisposalBackground disposal method. Config is the global color table (palette), width and height. A nil or empty-color.Palette Config.ColorModel means that each frame has its own color table and there is no global color table. Each frame's bounds must be within the rectangle defined by the two points (0, 0) and (Config.Width, Config.Height). For backwards compatibility, a zero-valued Config is valid to pass to EncodeAll, and implies that the overall GIF's width and height equals the first frame's bounds' Rectangle.Max point. // The successive delay times, one per frame, in 100ths of a second. Disposal is the successive disposal methods, one per frame. For backwards compatibility, a nil Disposal is valid to pass to EncodeAll, and implies that each frame's disposal method is 0 (no disposal specified). // The successive images. LoopCount controls the number of times an animation will be restarted during display. A LoopCount of 0 means to loop forever. A LoopCount of -1 means to show each frame only once. Otherwise, the animation is looped LoopCount+1 times. func DecodeAll(r io.Reader) (*GIF, error) func EncodeAll(w io.Writer, g *GIF) error
Options are the encoding parameters. Drawer is used to convert the source image to the desired palette. draw.FloydSteinberg is used in place of a nil Drawer. NumColors is the maximum number of colors used in the image. It ranges from 1 to 256. Quantizer is used to produce a palette with size NumColors. palette.Plan9 is used in place of a nil Quantizer. func Encode(w io.Writer, m image.Image, o *Options) error
Package-Level Functions (total 5)
Decode reads a GIF image from r and returns the first embedded image as an [image.Image]. When decoding images from untrusted sources, it is safest to first call DecodeConfig and check the image size so that unexpectedly large memory allocations may be safely avoided.
DecodeAll reads a GIF image from r and returns the sequential frames and timing information. Like [Decode], this allocates a paletted buffer per frame from width and height in the image descriptors. [DecodeAll] retains every decoded frame in memory. For untrusted input, call [DecodeConfig] first to verify the logical screen size and reject inputs that would require excessive memory.
DecodeConfig returns the global color model and dimensions of a GIF image without decoding the entire image. It reads the logical screen descriptor and global color table only; it does not allocate pixel buffers for frames. Use it to check width and height before calling [Decode] or [DecodeAll].
Encode writes the Image m to w in GIF format.
EncodeAll writes the images in g to w in GIF format with the given loop count and delay between frames.
Package-Level Constants (total 3)
Disposal Methods.
Disposal Methods.
Disposal Methods.