Documentation ¶
Index ¶
- Constants
- Variables
- func Format2Ext(f string) string
- func GetPoint(sm, wm image.Point, pos Position) (pt image.Point)
- func PatchFormat(s string) string
- func SaveTo(w io.Writer, m image.Image, opt *WriteOption) (n int, err error)
- func Thumbnail(r io.Reader, w io.Writer, topt *ThumbOption) error
- func ThumbnailFile(src, dest string, topt *ThumbOption) (err error)
- func ThumbnailImage(img image.Image, topt *ThumbOption) (image.Image, error)
- func ThumbnailImageTo(im image.Image, w io.Writer, topt *ThumbOption) error
- func Watermark(r, wr io.Reader, w io.Writer, wo WaterOption) error
- func WatermarkFile(src, wname, dest string, wo WaterOption) (err error)
- func WatermarkImage(img, water image.Image, pos Position, opacity Opacity) (image.Image, error)
- type Attr
- type CountWriter
- type Image
- type Imager
- type Opacity
- type Position
- type ThumbOption
- type WaterOption
- type WriteOption
Constants ¶
View Source
const ( MinJPEGQuality = jpeg.DefaultQuality // 75 MinWebpQuality = 80 )
consts
View Source
const ( FormatGIF = "gif" FormatJPEG = "jpeg" FormatPNG = "png" FormatWEBP = "webp" )
consts
View Source
const (
WebpEncodable = true
)
Variables ¶
View Source
var ( ErrInvalidFormat = errors.New("invalid image format") ErrUnsupportFormat = errors.New("unsupported image format") ErrOrigTooSmall = errors.New("original image too small") ErrEmptyImage = errors.New("image is empty") )
vars of errors
Functions ¶
func ThumbnailFile ¶
func ThumbnailFile(src, dest string, topt *ThumbOption) (err error)
ThumbnailFile ...
func ThumbnailImage ¶
ThumbnailImage ...
func ThumbnailImageTo ¶
ThumbnailImageTo ...
func WatermarkFile ¶
func WatermarkFile(src, wname, dest string, wo WaterOption) (err error)
WatermarkFile ...
Types ¶
type Attr ¶
type Attr struct { Width uint32 `json:"width"` Height uint32 `json:"height"` Size uint32 `json:"size,omitempty"` // Original size Quality uint8 `json:"qlt,omitempty"` // Original quality Ext string `json:"ext"` // file extension include dot Mime string `json:"mime,omitempty"` // content type }
Attr ...
type CountWriter ¶
type CountWriter struct {
// contains filtered or unexported fields
}
CountWriter ...
type Image ¶
Image ...
func (*Image) ThumbnailTo ¶
func (im *Image) ThumbnailTo(w io.Writer, topt *ThumbOption) error
ThumbnailTo ...
type Imager ¶
type Imager interface { SaveTo(w io.Writer, opt WriteOption) error ThumbnailTo(w io.Writer, topt ThumbOption) error }
Imager ...
type ThumbOption ¶
type ThumbOption struct {
Width, Height uint // 宽和高
MaxWidth, MaxHeight uint // 最大宽和高
IsFit bool // 是否保持比例
IsCrop bool // 是否裁切
CropX, CropY int // 裁切位置
WriteOption
// contains filtered or unexported fields
}
ThumbOption 缩图选项
func (ThumbOption) String ¶
func (topt ThumbOption) String() string
type WaterOption ¶
type WaterOption struct { Pos Position Opacity Opacity Filename string WriteOption }
WaterOption ...
Click to show internal directories.
Click to hide internal directories.