Documentation ¶
Index ¶
- Constants
- func AVIFEncode(ctx context.Context, img image.Image, quality int) (data []byte, err error)
- func BrotliEncode(buf []byte, quality int) ([]byte, error)
- func GzipEncode(buf []byte, quality int) ([]byte, error)
- func ImageCrop(img image.Image, cropType CropType, width, height int) image.Image
- func ImageResize(img image.Image, width, height int) image.Image
- func JPEGEncode(ctx context.Context, img image.Image, quality int) (data []byte, err error)
- func Lz4Encode(data []byte, quality int) ([]byte, error)
- func PNGEncode(ctx context.Context, img image.Image, quality int) (data []byte, err error)
- func SnappyEncode(buf []byte) ([]byte, error)
- func WEBPEncode(img image.Image, quality int) (data []byte, err error)
- func WebpDecode(reader io.Reader) (image.Image, error)
- func ZstdEncode(buf []byte, quality int) ([]byte, error)
- type Commander
- type CropType
- type EncodeType
- type Image
- type Text
Constants ¶
View Source
const ( // Gzip gzip Gzip = "gzip" // Br br Br = "br" // Snappy sz Snappy = "sz" // Lz4 lz4 Lz4 = "lz4" // Zstd zstd Zstd = "zstd" // JPEG jpeg JPEG = "jpeg" // PNG png PNG = "png" // WEBP webp WEBP = "webp" // AVIF avif AVIF = "avif" )
Variables ¶
This section is empty.
Functions ¶
func AVIFEncode ¶ added in v1.1.0
func BrotliEncode ¶
BrotliEncode brotli encode
func ImageResize ¶
ImageResize resize image
func JPEGEncode ¶
JPEGEncode jpeg encode
func WEBPEncode ¶
WEBPEncode webp encode
Types ¶
type CropType ¶
type CropType int
CropType crop type
const ( // CropNone none crop CropNone CropType = iota // CropLeftTop crop left top CropLeftTop // CropTopCenter crop top center CropTopCenter // CropRightTop crop right top CropRightTop // CropLeftCenter crop left center CropLeftCenter // CropCenterCenter crop center center CropCenterCenter // CropRightCenter crop right center CropRightCenter // CropLeftBottom crop left bottom CropLeftBottom // CropBottomCenter crop bottom center CropBottomCenter // CropRightBottom crop right bottom CropRightBottom )
type EncodeType ¶
type EncodeType int
EncodeType encode type
const ( // EncodeTypeUnknown unknown EncodeTypeUnknown EncodeType = iota // EncodeTypeGzip gzip EncodeTypeGzip // EncodeTypeBr br EncodeTypeBr // EncodeTypeSnappy snappy EncodeTypeSnappy // EncodeTypeLz4 lz4 EncodeTypeLz4 // EncodeTypeZstd zstd EncodeTypeZstd // EncodeTypeJPEG jpeg EncodeTypeJPEG // EncodeTypePNG png EncodeTypePNG // EncodeTypeWEBP webp EncodeTypeWEBP // EncodeTypeAVIF avif EncodeTypeAVIF )
func ConvertToEncodeType ¶
func ConvertToEncodeType(t string) EncodeType
ConvertToEncodeType convert to encode type
func (EncodeType) String ¶
func (t EncodeType) String() string
type Image ¶
type Image struct { Data []byte `json:"data,omitempty"` Type EncodeType `json:"type,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` }
Image image information
func ImageOptim ¶
func ImageOptim(ctx context.Context, buf []byte, sourceType, outputType EncodeType, cropType CropType, quality, width, height int) (imgInfo *Image, err error)
ImageOptim image optim
Click to show internal directories.
Click to hide internal directories.