Documentation
¶
Overview ¶
Package gif provides GIF decoding, encoding, and frame-level editing operations.
Index ¶
- Variables
- func AddText(gif *gifstd.GIF, opts TextOptions) (*gifstd.GIF, error)
- func Crop(gif *gifstd.GIF, cropOptions CropOptions) (*gifstd.GIF, error)
- func DecodeBytes(data []byte) (*gifstd.GIF, error)
- func DeepFry(gif *gifstd.GIF) (*gifstd.GIF, error)
- func EncodeBytes(gif *gifstd.GIF) ([]byte, error)
- func FlipH(g *gifstd.GIF) (*gifstd.GIF, error)
- func FlipV(g *gifstd.GIF) (*gifstd.GIF, error)
- func FramesToGIF(frames [][]byte, width, height, fps int, highQuality bool) (*gifstd.GIF, error)
- func Grayscale(gif *gifstd.GIF) (*gifstd.GIF, error)
- func ParseColor(str string) color.Color
- func Resize(gif *gifstd.GIF, width, height int) (*gifstd.GIF, error)
- func Reverse(g *gifstd.GIF) (*gifstd.GIF, error)
- func Rotate90CCW(g *gifstd.GIF) (*gifstd.GIF, error)
- func Rotate90CW(g *gifstd.GIF) (*gifstd.GIF, error)
- func Rotate180(g *gifstd.GIF) (*gifstd.GIF, error)
- func Speed(gif *gifstd.GIF, factor float64) (*gifstd.GIF, error)
- func Trim(gif *gifstd.GIF, start, end int) (*gifstd.GIF, error)
- type CropOptions
- type TextOptions
Constants ¶
This section is empty.
Variables ¶
var ( ErrCropDimensions = errors.New("crop dimensions must be positive") ErrCropOutOfBounds = errors.New("crop out of bounds") ErrDecodeGIF = errors.New("failed to decode GIF") ErrEncodeGIF = errors.New("failed to encode GIF") ErrNoFrames = errors.New("GIF has no frames") ErrInvalidDimensions = errors.New("GIF has invalid dimensions") ErrResizeDimensions = errors.New("invalid resize dimensions") ErrSpeedFactor = errors.New("speed factor must be positive") ErrLoadFont = errors.New("failed to load font") ErrInvalidFrameRange = errors.New("invalid frame range") ErrNoVideoFrames = errors.New("no frames extracted from video") ErrInvalidFPS = errors.New("frame rate must be between 1 and 60") )
Sentinel errors returned by gif processing functions.
Functions ¶
func DecodeBytes ¶
DecodeBytes decodes a GIF from a byte slice.
func DeepFry ¶
DeepFry applies an extreme saturation + contrast boost, warm tint, noise, and heavy sharpening to produce the classic "deep fried" meme look.
func EncodeBytes ¶
EncodeBytes encodes a GIF to a byte slice.
func FramesToGIF ¶ added in v1.1.0
FramesToGIF converts a sequence of raw RGBA frames into a GIF. Each frame must be width*height*4 bytes in RGBA order. fps must be between 1 and 60; the GIF frame delay is derived from it. If highQuality is true, each frame's palette is built using median cut quantization instead of the fixed Plan9 palette.
func ParseColor ¶
ParseColor converts a color name or hex string to a color.Color.
func Resize ¶
Resize scales every frame of the GIF to the given dimensions. Pass width=0 to auto-calculate from height, or height=0 to auto-calculate from width.
func Rotate90CCW ¶ added in v1.2.0
Rotate90CCW returns a new GIF with every frame rotated 90° counter-clockwise.
func Rotate90CW ¶ added in v1.2.0
Rotate90CW returns a new GIF with every frame rotated 90° clockwise.
Types ¶
type CropOptions ¶
type CropOptions struct {
X, Y, Width, Height int
}
CropOptions defines the region to crop, in pixels relative to the top-left of the GIF.