Documentation
¶
Index ¶
- func Compress(w io.Writer, g *gif.GIF, o *Options) error
- func CompressFromReader(w io.Writer, r io.Reader, o *Options) error
- type Gifsicle
- func (g *Gifsicle) Debug() *Gifsicle
- func (g *Gifsicle) Input(reader io.Reader) *Gifsicle
- func (g *Gifsicle) InputFile(file string) *Gifsicle
- func (g *Gifsicle) InputGif(inputGif *gif.GIF) *Gifsicle
- func (g *Gifsicle) Lossy(lossy uint) *Gifsicle
- func (g *Gifsicle) NumColors(numColors uint) *Gifsicle
- func (g *Gifsicle) OptimizeLevel(l OptimizeLevel) *Gifsicle
- func (g *Gifsicle) Output(writer io.Writer) *Gifsicle
- func (g *Gifsicle) OutputFile(file string) *Gifsicle
- func (g *Gifsicle) Reset() *Gifsicle
- func (g *Gifsicle) Run() error
- func (g *Gifsicle) Version() (string, error)
- type OptimizeLevel
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressFromReader ¶
Shortcut function to compress GIFs quickly and easily with gifsicle using an io.Reader like a file or buffer.
Example:
testFilePath := path.Join("testfiles", "portrait_3mb.gif") testFile, err := os.Open(testFilePath) if err != nil { return err } var buf bytes.Buffer err = gifsicle.CompressFromReader(&buf, testFile, &gifsicle.Options{ Lossy: 200, OptimizeLevel: gifsicle.OPTIMIZE_LEVEL_THREE, NumColors: 256, }) if err != nil { return err }
Types ¶
type Gifsicle ¶
type Gifsicle struct {
// contains filtered or unexported fields
}
Gifsicle wraps the gifsicle CLI tool.
func NewGifsicle ¶
func (*Gifsicle) Input ¶
Input sets reader to convert. InputFile or InputImage called before will be ignored.
func (*Gifsicle) InputFile ¶
InputFile sets image file to convert. Input or InputGif called before will be ignored.
func (*Gifsicle) InputGif ¶
InputGif sets gif to convert. InputFile or Input called before will be ignored.
func (*Gifsicle) Lossy ¶
Sets the --lossy parameter.
This parameter ranges from 0-200 (higher value -> more compression).
This is the main compression parameter used in websites like ezgif!
func (*Gifsicle) NumColors ¶
Sets the --colors parameter.
This parameter ranges from 2-256 (lower value -> more compression).
func (*Gifsicle) OptimizeLevel ¶
func (g *Gifsicle) OptimizeLevel(l OptimizeLevel) *Gifsicle
For the -O[level] or --optimize[=level] arguments.
See https://www.lcdf.org/gifsicle/man.html for more information.
func (*Gifsicle) Output ¶
Output specify writer to write jpeg file content. OutputFile called before will be ignored.
func (*Gifsicle) OutputFile ¶
OutputFile specify the name of the output jpeg file. Output called before will be ignored.
type OptimizeLevel ¶
type OptimizeLevel string
For the -O[level] or --optimize[=level] arguments.
See https://www.lcdf.org/gifsicle/man.html for more information.
var ( // Store only the changed portion of each image. This is the default. OPTIMIZE_LEVEL_ONE OptimizeLevel = "1" // Store only the changed portion of each image, and use transparency. OPTIMIZE_LEVEL_TWO OptimizeLevel = "2" // Tries several optimization methods (usually slower, sometimes better results). OPTIMIZE_LEVEL_THREE OptimizeLevel = "3" // Preserve empty transparent frames (they are dropped by default). OPTIMIZE_LEVEL_KEEP_EMPTY OptimizeLevel = "keep-empty" )
type Options ¶
type Options struct { // This parameter ranges from 0-200 (higher value -> more compression). // // This is the main compression parameter used in websites like ezgif! Lossy uint // Additional compression optimization. OptimizeLevel OptimizeLevel // Optional parameter to specify the number of colors (2-256) for the GIF // // Specifying less colors compresses the GIF more. // If this is 0, gifsicle will default to using the image's color map. NumColors uint }