encoder

package
v0.0.0-...-d7093dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package encoder responsible for merging multi frames to a gif or video

Index

Constants

This section is empty.

Variables

View Source
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

type EncodeOptions struct {
	convert.Options
	Delay time.Duration
}

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

func NewEncoder(filename string) (encoder Encoder, supported bool)

NewEncoder is a factory method to create a new encoder by file type

func NewGifEncoder

func NewGifEncoder() Encoder

NewGifEncoder create a new encoder

func NewImageEncoder

func NewImageEncoder() Encoder

NewImageEncoder create a new ImageEncoder

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL