tiny

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

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 AVIFEncode(ctx context.Context, img image.Image, quality int) (data []byte, err error)

func BrotliEncode

func BrotliEncode(buf []byte, quality int) ([]byte, error)

BrotliEncode brotli encode

func GzipEncode

func GzipEncode(buf []byte, quality int) ([]byte, error)

GzipEncode gzip compress

func ImageCrop

func ImageCrop(img image.Image, cropType CropType, width, height int) image.Image

ImageCrop crop image

func ImageResize

func ImageResize(img image.Image, width, height int) image.Image

ImageResize resize image

func JPEGEncode

func JPEGEncode(ctx context.Context, img image.Image, quality int) (data []byte, err error)

JPEGEncode jpeg encode

func Lz4Encode

func Lz4Encode(data []byte, quality int) ([]byte, error)

Lz4Encode lz4 encode

func PNGEncode

func PNGEncode(ctx context.Context, img image.Image, quality int) (data []byte, err error)

PNGEncode png encode

func SnappyEncode

func SnappyEncode(buf []byte) ([]byte, error)

SnappyEncode snappy encode

func WEBPEncode

func WEBPEncode(img image.Image, quality int) (data []byte, err error)

WEBPEncode webp encode

func WebpDecode

func WebpDecode(reader io.Reader) (image.Image, error)

WebpDecode webp decode

func ZstdEncode

func ZstdEncode(buf []byte, quality int) ([]byte, error)

ZstdEncode zstd encode

Types

type Commander

type Commander func(string, string) []string

Commander commander

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

type Text

type Text struct {
	Data []byte     `json:"data,omitempty"`
	Type EncodeType `json:"type,omitempty"`
}

Text text information

func TextOptim

func TextOptim(data []byte, outputType EncodeType, quality int) (info *Text, err error)

TextOptim text optim

Jump to

Keyboard shortcuts

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