imageKit

package
v3.1.112 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Decode func(r io.Reader) (img image.Image, format string, err error) = image.Decode

Decode 解码图片(部分特殊格式不支持; path => image.Image).

@param r 类型可以是: *os.File(用完记得调用Close()) @return 第1个: image.Image实例

第2个: 表示图像的格式名称,例如 "png"、"jpeg" 等(不带"." && 转为小写)
第3个: error(可能为nil)

Functions

func DecodeFromBase64

func DecodeFromBase64(base64 []byte) ([]byte, error)

DecodeFromBase64 图片的base64数据 => 图片的数据(可以直接存储到硬盘上)

@param base64 带不带前缀都无所谓(e.g. "data:image/png;base64,"、"data:image/jpeg;base64,"、"data:image/gif;base64,")

func DecodeToImageFile

func DecodeToImageFile(base64 []byte, dest string, perm os.FileMode) error

DecodeToImageFile

@param target 要生成的图片的路径

func DecodeWithBytes added in v3.0.106

func DecodeWithBytes(imgData []byte) (img image.Image, format string, err error)

DecodeWithBytes []byte => image.Image

func DecodeWithImagePath added in v3.0.106

func DecodeWithImagePath(imgPath string) (img image.Image, format string, err error)

DecodeWithImagePath 解码图片.

@param imagePath 图片的路径.

func EncodeToBase64String

func EncodeToBase64String(data []byte) (string, error)

func GetImageBase64

func GetImageBase64(imagePath string) (string, error)

GetImageBase64 (硬盘上的)图片 => base64字符串

参考: golang 将图片生成Base64 https://blog.csdn.net/weixin_40292098/article/details/126029489

func GetSize added in v3.0.106

func GetSize(path string) (width int, height int, err error)

GetSize 获取图片的宽和高.

PS: 单位为像素(px).

func GetWebImageBase64

func GetWebImageBase64(url string) (string, error)

GetWebImageBase64 网络图片 => base64字符串

参考: golang 将图片生成Base64 https://blog.csdn.net/weixin_40292098/article/details/126029489

@param url e.g."https://img.redocn.com/sheying/20150507/pugongying_4267498.jpg"

func ToBmp

func ToBmp(src, dest string) error

ToBmp 将图片格式转换为".bmp".

func ToJpeg

func ToJpeg(src, dest string, qualityArgs ...int8) error

ToJpeg 将图片格式转换为".jpg"(||".jpeg").

@param qualityArgs (默认: 100; 取值范围: [1, 100])生成jpeg图片的质量

func ToPng

func ToPng(src, dest string) error

ToPng 将图片格式转换为".png".

func ToTiff

func ToTiff(src, dest string, opts *tiff.Options) error

ToTiff 将图片格式转换为".tiff".

Types

type Info

type Info struct {
	ExtName    string      `json:"extName"`
	ColorModel color.Model `json:"colorModel"`

	Width  int `json:"width"`
	Height int `json:"height"`
}

func GetInfo

func GetInfo(path string) (*Info, error)

GetInfo 获取图片的信息(宽、高、后缀名).

【图像处理】Golang 获取常用图像的宽高总结

https://www.cnblogs.com/voipman/p/16108320.html

Jump to

Keyboard shortcuts

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