imgresize

package
v0.0.0-...-790eabe Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MulanPSL-2.0 Imports: 8 Imported by: 0

README

imgresize

图片压缩大小工具。

  • Do:执行压缩函数。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(imgFilepath string, params Params) (buf []byte, contentType string, err error)

执行压缩的函数

Types

type Converter

type Converter interface {
	// 转换
	Convert(fileObj *os.File, params Params) (imageBuf bytes.Buffer, err error)
}

通用方法

type ImageConverterJPG

type ImageConverterJPG struct {
}

func (ImageConverterJPG) Convert

func (ImageConverterJPG) Convert(fileObj *os.File, params Params) (imageBuf bytes.Buffer, err error)

func (ImageConverterJPG) IsFormat

func (ImageConverterJPG) IsFormat(contentTypeName string) bool

type ImageConverterPNG

type ImageConverterPNG struct {
}

func (ImageConverterPNG) Convert

func (ImageConverterPNG) Convert(fileObj *os.File, params Params) (imageBuf bytes.Buffer, err error)

type Params

type Params struct {
	Width   uint // 宽度,如果为0,则表示是等比例缩放
	Height  uint // 高度,如果为0,则表示是等比例缩放
	Quality int  // 质量,0-100
}

压缩参数

Jump to

Keyboard shortcuts

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