Documentation ¶
Index ¶
- Variables
- func Convert(src, dest string) error
- func DecodeFromBase64(base64 []byte) ([]byte, error)
- func DecodeToImageFile(base64 []byte, dest string) error
- func DecodeWithPath(src string) (image.Image, string, error)
- func EncodeToBase64String(data []byte) (string, error)
- func GetImageBase64(imagePath string) (string, error)
- func GetImageType(path string) (bimg.ImageType, error)
- func GetWebImageBase64(url string) (string, error)
- func ToJpeg(src, dest string, qualityArgs ...int8) error
- func ToPng(src, dest string) error
- type Info
Constants ¶
This section is empty.
Variables ¶
Decode 解码图片
@param r 类型可以是: *os.File(用完记得调用Close())
Functions ¶
func Convert ¶ added in v2.1.18
Convert 转换图片的格式.
!!!: (1) 因为 h2non/bimg 基于C语言的libvip库,因此使用要满足"一些条件",详见: https://mp.weixin.qq.com/s/kAFZohzJo2DiKkxjnVti6A (2) bug: 转换后,透明背景色 可能=> 黑色背景色(即使目标格式支持透明背景色); (3) bug: 图片转pdf.
@param dest 如果已经存在且是个文件,会覆盖
支持的格式:
"jpg" "jpeg" "png" "webp" "tiff" "gif" "pdf" "svg" "magick" "heif" "avif"
func DecodeFromBase64 ¶
DecodeFromBase64 图片的base64数据 => 图片的数据(可以直接存储到硬盘上)
@param base64 带不带前缀都无所谓(e.g. "data:image/png;base64,"、"data:image/jpeg;base64,"、"data:image/gif;base64,")
func DecodeWithPath ¶ added in v2.1.18
DecodeWithPath 解码图片
func EncodeToBase64String ¶
func GetImageBase64 ¶
GetImageBase64 (硬盘上的)图片 => base64字符串
参考: golang 将图片生成Base64 https://blog.csdn.net/weixin_40292098/article/details/126029489
func GetImageType ¶ added in v2.1.18
GetImageType 根据 文件名 判断图片类型.
func GetWebImageBase64 ¶
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"