ximg

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MulanPSL-2.0 Imports: 15 Imported by: 0

README

ximg

介绍
  • 对图片进行 压缩, 裁剪 操作

Documentation

Index

Constants

View Source
const (
	DirectResize     uint8 // 直接压缩
	EqualRatioResize       // 等比压缩
)

Variables

This section is empty.

Functions

func Bmp

func Bmp(dest io.Writer, src multipart.File, fn ...ToImgFn) error

Bmp

func GetSize

func GetSize(path string) (int64, error)

GetSize 获取文件大小

func Gif

func Gif(dest io.Writer, src multipart.File, opt *gif.Options, fn ...ToImgFn) error

Gif

func Jpeg

func Jpeg(dest io.Writer, src multipart.File, quality int, fn ...ToImgFn) error

Jpeg 处理 jpg, jpeg

func Png

func Png(dest io.Writer, src multipart.File, fn ...ToImgFn) error

Png

func Rotate180 added in v1.2.4

func Rotate180(m image.Image) image.Image

Rotate180 旋转180度

func Rotate270 added in v1.2.4

func Rotate270(m image.Image) image.Image

Rotate270 旋转270度

func Rotate90 added in v1.2.4

func Rotate90(m image.Image) image.Image

Rotate90 旋转90度

func ValidPicFmt added in v1.2.3

func ValidPicFmt(filename string, mustFmt ...[]string) bool

ValidPicFmt 验证图片格式

func Webp

func Webp(dest io.Writer, src multipart.File, fn ...ToImgFn) error

Webp

Types

type ToImgFn

type ToImgFn func(image.Image) image.Image

ToImgFn 图片处理

type XImg

type XImg struct {
	SysSplit string // 系统路径分隔符
	FileName string // 文件名
	// contains filtered or unexported fields
}

func NewXImg

func NewXImg(src interface{}) (*XImg, error)

NewXImg 初始化

func (*XImg) Compress

func (x *XImg) Compress(dest string, quality int) (destFileName string, err error)

Compress 压缩图片 dest 为目标文件路径 quality 为压缩比, 如果不想设置请设置 -1, 暂时只支持 jpeg, jpg

func (*XImg) GetImgFmt

func (x *XImg) GetImgFmt() string

GetImgFmt 获取文件格式

func (*XImg) Resize

func (x *XImg) Resize(dest string, newW, newH uint, quality int, resizeType ...uint8) (destFileName string, err error)

Resize 修改尺寸 dest 为目标文件路径 newW 新的宽度 newH 新的高度 quality 为压缩比, 如果不想设置请设置 -1, 暂时只支持 jpeg, jpg resizeType 压缩类型

func (*XImg) SetHandleFn added in v1.2.4

func (x *XImg) SetHandleFn(fn func(image.Image) image.Image)

SetHandleFn 这种处理函数

Jump to

Keyboard shortcuts

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