Documentation ¶
Overview ¶
Package encoder responsible for merging multi frames to a gif or video
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultEncodeOptions = EncodeOptions{ Options: convert.DefaultOptions, Delay: time.Duration(100) * time.Millisecond, }
DefaultEncodeOptions is default and recommend options for encoding
Functions ¶
This section is empty.
Types ¶
type EncodeOptions ¶
EncodeOptions define the required options to encode
type Encoder ¶
type Encoder interface { Encode(writer io.Writer, frames []image.Image, progress chan<- int) error EncodeToFile(filename string, frames []image.Image, progress chan<- int) error }
Encoder interface is used to encode the multi frames to a gif file or encode frames to a video
func NewEncoder ¶
NewEncoder is a factory method to create a new encoder by file type
type GifEncoder ¶
type GifEncoder struct { }
GifEncoder is responsible for encode the frames into gif
func (*GifEncoder) Encode ¶
func (gifEncoder *GifEncoder) Encode(writer io.Writer, frames []image.Image, progress chan<- int) error
Encode encode frames into a io writer
func (*GifEncoder) EncodeToFile ¶
func (gifEncoder *GifEncoder) EncodeToFile(gifFilename string, frames []image.Image, progress chan<- int) error
EncodeToFile encode frames into a file by file name
type ImageEncoder ¶
type ImageEncoder struct {
Filename string
}
ImageEncoder is responsible for encoding image
func (*ImageEncoder) Encode ¶
func (encoder *ImageEncoder) Encode(writer io.Writer, frames []image.Image, progress chan<- int) error
Encode for ImageEncoder just encode the image, if the frame slice contain many frame, only pick up the first one.
func (*ImageEncoder) EncodeToFile ¶
func (encoder *ImageEncoder) EncodeToFile(filename string, frames []image.Image, progress chan<- int) error
EncodeToFile encode the frames to the file by filename