henshin

package
v0.0.0-...-652f125 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BiLinearStrategy = draw.BiLinear
	NearestStrategy  = draw.NearestNeighbor
)

Functions

func Decode

func Decode(r io.Reader, o *DecodeOptions) (image.Image, error)

Decode decodes an image that has been encoded in a format understood by a registered codec.

func Encode

func Encode(name string, w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes an image into the registered codec corresponding to the specified name.

func RegisterCodec

func RegisterCodec(c Codec)

RegisterCodec registers a new image processing codec.

Types

type BMPCodec

type BMPCodec struct{}

BMPCodec is the BMP codec.

func (*BMPCodec) Aliases

func (c *BMPCodec) Aliases() []string

Aliases returns alternate names for the BMP codec

func (*BMPCodec) Decode

func (c *BMPCodec) Decode(r io.Reader, d *DecodeOptions) (image.Image, error)

Decode decodes a BMP image according to the options specified.

func (*BMPCodec) DecodeConfig

func (c *BMPCodec) DecodeConfig(r io.Reader, d *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a BMP image without decoding the image.

func (*BMPCodec) Encode

func (c *BMPCodec) Encode(w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes a BMP image according to the options specified.

func (*BMPCodec) Magic

func (c *BMPCodec) Magic() []string

Magic returns magic strings that identify BMP data.

func (*BMPCodec) Name

func (c *BMPCodec) Name() string

Name returns the name of the BMP codec: "bmp"

func (*BMPCodec) New

func (c *BMPCodec) New() Codec

New returns a new instance of BMPCodec.

type Codec

type Codec interface {
	Name() string
	New() Codec
}

Codec is any named image codec.

func Codecs

func Codecs() (ret []Codec)

Codecs returns a list of all codecs.

func NewCodec

func NewCodec(name string) (Codec, error)

NewCodec creates a new instance of the codec corresponding to the specified name.

type CodecWithAliases

type CodecWithAliases interface {
	Codec
	Aliases() []string
}

CodecWithAliases is an image codec that can have alternate names. Use this if you want to support format autodetection for multiple file extensions.

type CodecWithParamParser

type CodecWithParamParser interface {
	Codec
	ParseParams(opt string) (any, error)
}

CodecWithParamParser is an image codec that allows getting codec-specific parameters from a string.

type DecodeOptions

type DecodeOptions struct {
	// Metadata is any metadata or additional properties associated
	// with the image. Set this to an empty metadata struct in order
	// to read this data.
	Metadata *Metadata

	// Strict tells the decoder whether or not to strictly parse even
	// non-critical metadata.
	Strict bool

	// DecoderSpecific is decoder-specific options.
	DecoderSpecific any
}

DecodeOptions specifies options for image decoders.

func DefaultDecodeOptions

func DefaultDecodeOptions() *DecodeOptions

DefaultDecodeOptions returns the default decoding options.

type Decoder

type Decoder interface {
	Codec
	Magic() []string
	Decode(io.Reader, *DecodeOptions) (image.Image, error)
	DecodeConfig(io.Reader, *DecodeOptions) (image.Config, error)
}

Decoder is an image codec that can decode.

type EncodeOptions

type EncodeOptions struct {
	// CompressionLevel is the compression level to use, on a scale
	// of 0 to 100. A value of 0 indicates no compression for PNG,
	// and 100% quality for JPEG. Other codecs may interpret this
	// value differently.
	CompressionLevel int

	// Metadata is any metadata or additional properties associated
	// with the image.
	Metadata *Metadata

	// EncoderSpecific is encoder-specific options.
	EncoderSpecific any
}

EncodeOptions specifies options for image encoders.

func DefaultEncodeOptions

func DefaultEncodeOptions() *EncodeOptions

DefaultEncodeOptions returns the default encoding options.

type Encoder

type Encoder interface {
	Codec
	Encode(io.Writer, image.Image, *EncodeOptions) error
}

Encoder is an image codec that can encode.

type ErrNoSuchCodec

type ErrNoSuchCodec string

func (ErrNoSuchCodec) Error

func (e ErrNoSuchCodec) Error() string

type GIFCodec

type GIFCodec struct{}

GIFCodec is the GIF codec.

func (*GIFCodec) Decode

func (c *GIFCodec) Decode(r io.Reader, d *DecodeOptions) (image.Image, error)

Decode decodes a GIF image according to the options specified.

func (*GIFCodec) DecodeConfig

func (c *GIFCodec) DecodeConfig(r io.Reader, d *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a GIF image without decoding the image.

func (*GIFCodec) Encode

func (c *GIFCodec) Encode(w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes a GIF image according to the options specified.

func (*GIFCodec) Magic

func (c *GIFCodec) Magic() []string

Magic returns magic strings that identify GIF data.

func (*GIFCodec) Name

func (c *GIFCodec) Name() string

Name returns the name of the GIF codec: "gif"

func (*GIFCodec) New

func (c *GIFCodec) New() Codec

New returns a new instance of GIFCodec.

type JPEGCodec

type JPEGCodec struct{}

JPEGCodec is the JPEG codec.

func (*JPEGCodec) Aliases

func (c *JPEGCodec) Aliases() []string

Aliases returns alternate names for the JPEG codec

func (*JPEGCodec) Decode

func (c *JPEGCodec) Decode(r io.Reader, d *DecodeOptions) (image.Image, error)

Decode decodes a JPEG image according to the options specified.

func (*JPEGCodec) DecodeConfig

func (c *JPEGCodec) DecodeConfig(r io.Reader, d *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a JPEG image without decoding the image.

func (*JPEGCodec) Encode

func (c *JPEGCodec) Encode(w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes a JPEG image according to the options specified.

func (*JPEGCodec) Magic

func (c *JPEGCodec) Magic() []string

Magic returns magic strings that identify JPEG data.

func (*JPEGCodec) Name

func (c *JPEGCodec) Name() string

Name returns the name of the JPEG codec: "jpeg"

func (*JPEGCodec) New

func (c *JPEGCodec) New() Codec

New returns a new instance of JPEGCodec.

type Metadata

type Metadata struct {
	// Text contains key-value pairs of text data.
	Text TextData

	// Comments contains a list of comments for the image.
	Comments []string

	// Specific contains encoder/decoder specific data.
	Specific any
}

Metadata is additional image metadata.

func (*Metadata) Clone

func (md *Metadata) Clone() *Metadata

type NetPBMCodec

type NetPBMCodec struct {
	Format netpbm.Format
}

NetPBMCodec is the NetPBM codec.

func (*NetPBMCodec) Decode

func (c *NetPBMCodec) Decode(r io.Reader, d *DecodeOptions) (image.Image, error)

Decode decodes a NetPBM image according to the options specified.

func (*NetPBMCodec) DecodeConfig

func (c *NetPBMCodec) DecodeConfig(r io.Reader, d *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a NetPBM image without decoding the image.

func (*NetPBMCodec) Encode

func (c *NetPBMCodec) Encode(w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes a NetPBM image according to the options specified.

func (*NetPBMCodec) Magic

func (c *NetPBMCodec) Magic() []string

Magic returns magic strings that identify NetPBM data.

func (*NetPBMCodec) Name

func (c *NetPBMCodec) Name() string

Name returns the name of the NetPBM codec: "netpbm"

func (*NetPBMCodec) New

func (c *NetPBMCodec) New() Codec

New returns a new instance of NetPBMCodec.

type PNGCodec

type PNGCodec struct {
	// contains filtered or unexported fields
}

PNGCodec is the still PNG codec.

func (*PNGCodec) Decode

func (c *PNGCodec) Decode(r io.Reader, o *DecodeOptions) (image.Image, error)

Decode decodes a PNG according to the options specified.

func (*PNGCodec) DecodeConfig

func (c *PNGCodec) DecodeConfig(r io.Reader, o *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a PNG image without decoding the image.

func (*PNGCodec) Encode

func (c *PNGCodec) Encode(w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes a PNG according to the options specified.

func (*PNGCodec) Magic

func (c *PNGCodec) Magic() []string

Magic returns magic strings that identify PNG data.

func (*PNGCodec) Name

func (c *PNGCodec) Name() string

Name returns the name of the PNG codec: "png"

func (*PNGCodec) New

func (c *PNGCodec) New() Codec

New returns a new instance of PNGCodec.

type QOICodec

type QOICodec struct{}

QOICodec is the QOI codec.

func (*QOICodec) Decode

func (c *QOICodec) Decode(r io.Reader, d *DecodeOptions) (image.Image, error)

Decode decodes a QOI image according to the options specified.

func (*QOICodec) DecodeConfig

func (c *QOICodec) DecodeConfig(r io.Reader, d *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a QOI image without decoding the image.

func (*QOICodec) Encode

func (c *QOICodec) Encode(w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes a QOI image according to the options specified.

func (*QOICodec) Magic

func (c *QOICodec) Magic() []string

Magic returns magic strings that identify QOI data.

func (*QOICodec) Name

func (c *QOICodec) Name() string

Name returns the name of the QOI codec: "qoi"

func (*QOICodec) New

func (c *QOICodec) New() Codec

New returns a new instance of QOICodec.

type ResizeStrategy

type ResizeStrategy = draw.Interpolator

ResizeStrategy is an interpolation strategy for resizing images.

type TIFFCodec

type TIFFCodec struct{}

TIFFCodec is the TIFF codec.

func (*TIFFCodec) Aliases

func (c *TIFFCodec) Aliases() []string

Aliases returns alternate names for the TIFF codec

func (*TIFFCodec) Decode

func (c *TIFFCodec) Decode(r io.Reader, d *DecodeOptions) (image.Image, error)

Decode decodes a TIFF image according to the options specified.

func (*TIFFCodec) DecodeConfig

func (c *TIFFCodec) DecodeConfig(r io.Reader, d *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a TIFF image without decoding the image.

func (*TIFFCodec) Encode

func (c *TIFFCodec) Encode(w io.Writer, i image.Image, o *EncodeOptions) error

Encode encodes a TIFF image according to the options specified.

func (*TIFFCodec) Magic

func (c *TIFFCodec) Magic() []string

Magic returns magic strings that identify TIFF data.

func (*TIFFCodec) Name

func (c *TIFFCodec) Name() string

Name returns the name of the TIFF codec: "tiff"

func (*TIFFCodec) New

func (c *TIFFCodec) New() Codec

New returns a new instance of TIFFCodec.

type TextData

type TextData []*TextEntry

func NewTextData

func NewTextData() TextData

func NewTextDataFromStringMap

func NewTextDataFromStringMap(strMap map[string]string) TextData

func (*TextData) Add

func (td *TextData) Add(te *TextEntry)

func (*TextData) AddString

func (td *TextData) AddString(key, value string)

func (TextData) Get

func (td TextData) Get(key string) (value *TextEntry, ok bool)

func (TextData) GetString

func (td TextData) GetString(key string) (value string, ok bool)

func (*TextData) Set

func (td *TextData) Set(te *TextEntry) (replaced bool)

func (*TextData) SetString

func (td *TextData) SetString(key, value string) (replaced bool)

func (TextData) ToStringMap

func (td TextData) ToStringMap() (ret map[string]string)

type TextEntry

type TextEntry struct {
	Key, Value string

	Language, Utf8Key string
	IsUtf8, Compress  bool
}

type WEBPCodec

type WEBPCodec struct{}

WEBPCodec is the WEBP codec.

func (*WEBPCodec) Decode

func (c *WEBPCodec) Decode(r io.Reader, d *DecodeOptions) (image.Image, error)

Decode decodes a WEBP image according to the options specified.

func (*WEBPCodec) DecodeConfig

func (c *WEBPCodec) DecodeConfig(r io.Reader, d *DecodeOptions) (image.Config, error)

DecodeConfig returns the color model and dimensions of a WEBP image without decoding the image.

func (*WEBPCodec) Magic

func (c *WEBPCodec) Magic() []string

Magic returns magic strings that identify WEBP data.

func (*WEBPCodec) Name

func (c *WEBPCodec) Name() string

Name returns the name of the WEBP codec: "webp"

func (*WEBPCodec) New

func (c *WEBPCodec) New() Codec

New returns a new instance of WEBPCodec.

type Wand

type Wand struct {
	// contains filtered or unexported fields
}

func NewWand

func NewWand() *Wand

func (*Wand) AddComment

func (w *Wand) AddComment(comment string)

func (*Wand) Clone

func (w *Wand) Clone() *Wand

func (*Wand) Comments

func (w *Wand) Comments() []string

func (*Wand) Crop

func (w *Wand) Crop(iw, ih, xoff, yoff int)

func (*Wand) CropAnchor

func (w *Wand) CropAnchor(iw, ih int, anchor string)

func (*Wand) DecodeImage

func (w *Wand) DecodeImage(r io.Reader) error

func (*Wand) EncodeImage

func (w *Wand) EncodeImage(wr io.Writer, codec string) error

func (*Wand) ForceRGBA

func (w *Wand) ForceRGBA()

func (*Wand) FormatString

func (w *Wand) FormatString(fmt string) (ret string)

func (*Wand) Hash

func (w *Wand) Hash() uint64

func (*Wand) Height

func (w *Wand) Height() int

func (*Wand) Image

func (w *Wand) Image() image.Image

func (*Wand) Metadata

func (w *Wand) Metadata() *Metadata

func (*Wand) NewImage

func (w *Wand) NewImage(iw, ih int)

func (*Wand) ReadImage

func (w *Wand) ReadImage(path string) error

func (*Wand) Resize

func (w *Wand) Resize(iw, ih int, strategy ResizeStrategy)

func (*Wand) ResizeArea

func (w *Wand) ResizeArea(area int, strategy ResizeStrategy)

func (*Wand) SetComments

func (w *Wand) SetComments(comments []string)

func (*Wand) SetCompressionLevel

func (w *Wand) SetCompressionLevel(l int)

func (*Wand) SetCompressionQuality

func (w *Wand) SetCompressionQuality(q int)

func (*Wand) SetImage

func (w *Wand) SetImage(im image.Image)

func (*Wand) Strip

func (w *Wand) Strip()

func (*Wand) Width

func (w *Wand) Width() int

func (*Wand) WriteImage

func (w *Wand) WriteImage(path string) error

Jump to

Keyboard shortcuts

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