Documentation
¶
Overview ¶
Package encoder provides the encoder registration mechanisms for iv.
An encoder writes a decoded image to a writer, either as a file format (png, jpeg, webp) or as terminal graphics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotRegistered is returned when no encoder is registered under a name. ErrNotRegistered = errors.New("encoder not registered") )
Functions ¶
func Unregister ¶
Unregister removes the named encoder. Returns whether it was registered. Not used by iv itself; provided for tests.
Types ¶
type EncodeFunc ¶
EncodeFunc encodes an image to a writer.
type Entry ¶
type Entry struct {
// Name is the unique encoder name.
Name string
// Desc is the human readable description.
Desc string
// Ext is the output file extension, without a leading dot. Empty for
// terminal encoders.
Ext string
// Term indicates the encoder writes terminal graphics rather than a file
// format.
Term bool
// contains filtered or unexported fields
}
Entry is a registered iv image encoder.
func TermEncoders ¶
func TermEncoders() []*Entry
TermEncoders returns the terminal graphics encoders, ordered by name.
func (*Entry) Encode ¶
Encode encodes the image to the writer. If the image kept an error while it was encoded (see ivimg.Err), Encode returns that error, because the output then does not show the image.
func (*Entry) EncodeSource ¶ added in v0.24.0
EncodeSource writes the decoded image to the writer, before the image is scaled and composited, when the encoder takes it as it is (see Source). It returns false when the encoder does not take it, and has then written nothing. The image is then prepared, and given to Entry.Encode.
type Option ¶
type Option func(*Entry)
Option is an encoder option.
func Encoder ¶
func Encoder(f EncodeFunc) Option
Encoder is an encoder option to set the encoding func.
func Extension ¶
Extension is an encoder option to set the output file extension, without a leading dot.
func ImageEncoder ¶
ImageEncoder is an encoder option setting the encoding func from a plain image encoder, such as [png.Encode]. The encoder gets the pixels under each wrapper of the image (see ivimg.Unwrap), because the encoders of the standard library are fast only for their own concrete types.
func Source ¶ added in v0.24.0
func Source(f SourceFunc) Option
Source is an encoder option to set the func that writes a decoded image before it is scaled and composited. See Entry.EncodeSource.
type SourceFunc ¶ added in v0.24.0
SourceFunc writes a decoded image to a writer before the image is scaled and composited, such as a document that keeps its vectors. It returns false when it does not take the image, and has then written nothing.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package all registers every iv encoder.
|
Package all registers every iv encoder. |
|
Package avif supplies an avif encoder for iv, in pure Go.
|
Package avif supplies an avif encoder for iv, in pure Go. |
|
Package gif supplies a gif encoder for iv, in Go.
|
Package gif supplies a gif encoder for iv, in Go. |
|
Package heic supplies a heic encoder for iv, in pure Go.
|
Package heic supplies a heic encoder for iv, in pure Go. |
|
Package jpeg supplies a jpeg encoder for iv.
|
Package jpeg supplies a jpeg encoder for iv. |
|
Package jpeg2000 supplies a jpeg 2000 encoder for iv, in pure Go.
|
Package jpeg2000 supplies a jpeg 2000 encoder for iv, in pure Go. |
|
Package jxl supplies a jpeg xl encoder for iv, in pure Go.
|
Package jxl supplies a jpeg xl encoder for iv, in pure Go. |
|
Package pdf supplies a pdf encoder for iv.
|
Package pdf supplies a pdf encoder for iv. |
|
Package png supplies a png encoder for iv.
|
Package png supplies a png encoder for iv. |
|
Package rasterm supplies the terminal graphics encoder for iv.
|
Package rasterm supplies the terminal graphics encoder for iv. |
|
Package tiff supplies a tiff encoder for iv, in Go.
|
Package tiff supplies a tiff encoder for iv, in Go. |
|
Package webp supplies the webp encoders for iv, in pure Go (D63).
|
Package webp supplies the webp encoders for iv, in pure Go (D63). |