Documentation ¶
Overview ¶
Package encode provides methods for encoding images.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterEncoder ¶
func RegisterEncoder(ctx context.Context, f InitializeEncoderFunc, schemes ...string) error
RegisterEncoder registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Encoder` instances by the `NewEncoder` method.
Types ¶
type Encoder ¶
type Encoder interface { // Encode encode and writes an `image.Image` instance to a `io.Writer` instance. Encode(context.Context, io.Writer, image.Image) error }
Encoder is an interface for writing data to multiple sources or targets.
func NewEncoder ¶
NewEncoder returns a new `Encoder` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `EncoderInitializationFunc` function used to instantiate the new `Encoder`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterEncoder` method.
func NewGIFEncoder ¶
NewGIFEncoder returns a new `GIFEncoder` instance. 'uri' in the form of:
/path/to/image.gif
func NewJPEGEncoder ¶
NewJPEGEncoder returns a new `JPEGEncoder` instance. 'uri' in the form of:
/path/to/image.jpg?{OPTIONS}
Where {OPTIONS} are:
- ?quality={QUALITY} - an optional value specifying the quality of the JPEG image; default is 100.
type GIFEncoder ¶
type GIFEncoder struct { Encoder // contains filtered or unexported fields }
GIFEncoder is a struct that implements the `Encoder` interface for encoding GIF images.
type InitializeEncoderFunc ¶
EncoderInitializationFunc is a function defined by individual encoder package and used to create an instance of that encoder.
type JPEGEncoder ¶
type JPEGEncoder struct { Encoder // contains filtered or unexported fields }
JPEGEncoder is a struct that implements the `Encoder` interface for encoding JPEG images.
type PNGEncoder ¶
type PNGEncoder struct {
Encoder
}
PNGEncoder is a struct that implements the `Encoder` interface for encoding PNG images.