imagex

package module
v0.0.0-...-e9726fd Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

README

imagex

Obtain basic information such as image width and height format size through image link. 通过图片链接获取图片宽高、格式、尺寸信息。

Documentation

Index

Constants

View Source
const (
	ProcessIdentificationAliCloud  = "?x-oss-process=image/info"
	ProcessIdentificationQiNiu     = "?imageMogr2"
	ProcessIdentificationByteDance = "~tplv-"
)

各服务商图片处理标识

View Source
const (
	BasicInfoSuffixAliCloud  = "?x-oss-process=image/info"
	BasicInfoSuffixQiNiu     = "?imageInfo"
	BasicInfoSuffixByteDance = "~info"
)

Variables

This section is empty.

Functions

func GetOssOriginalUrl

func GetOssOriginalUrl(imgUrl string) string

GetOssOriginalUrl 获取 OSS 图片未做处理链接

func GetOssOriginalUrlWithIdf

func GetOssOriginalUrlWithIdf(imgUrl, idf string) string

GetOssOriginalUrlWithIdf 通过 ProcessIdentification 获取 OSS 图片未做处理链接

func IsWebpUrl

func IsWebpUrl(imgUrl string) bool

IsWebpUrl 是否是 webp url

func ParseImage

func ParseImage(imgUrl string) (image.Image, string, error)

ParseImage 常规解析图片信息 支持 gif/jpeg/png 暂不支持 webp

Types

type AliOssImageInfo

type AliOssImageInfo struct {
	FileSize struct {
		Value string `json:"value"`
	} `json:"FileSize"`
	Format struct {
		Value string `json:"value"`
	} `json:"Format"`
	ImageHeight struct {
		Value string `json:"value"`
	} `json:"ImageHeight"`
	ImageWidth struct {
		Value string `json:"value"`
	} `json:"ImageWidth"`
}

AliOssImageInfo 阿里云图片基本信息 Example: http://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/info

type ImageInfo

type ImageInfo struct {
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Format string `json:"format"`
	Size   int    `json:"size"`
}

ImageInfo 公共图片信息(七牛云/字节可通用) Example: 七牛 http://dn-odum9helk.qbox.me/resource/gogopher.jpg?imageInfo Example: 字节 http://p3-imagex.byteimg.com/imagex-rc/preview.jpg~info

func ParseAliOssImageInfo

func ParseAliOssImageInfo(imgUrl string) (*ImageInfo, error)

ParseAliOssImageInfo 解析阿里云图片基本信息 imgUrl 需为去除 OSS 图片处理参数后的链接,可参考 GetOssOriginalUrl 去除 ApiDoc: https://help.aliyun.com/document_detail/44975.html

func ParseByteDanceImageInfo

func ParseByteDanceImageInfo(imgUrl string) (*ImageInfo, error)

ParseByteDanceImageInfo 解析七牛云/字节图片基本信息 imgUrl 需为去除 OSS 图片处理参数后的链接,可参考 GetOssOriginalUrl 去除 ApiDoc: 字节 https://www.volcengine.com/docs/508/64085

func ParseOssImageInfo

func ParseOssImageInfo(imgUrl string) (*ImageInfo, error)

ParseOssImageInfo 解析OSS服务商图片信息 PS: 适用无图片处理后缀场景

func ParseQiNiuImageInfo

func ParseQiNiuImageInfo(imgUrl string) (*ImageInfo, error)

ParseQiNiuImageInfo 解析七牛云图片基本信息 imgUrl 需为去除 OSS 图片处理参数后的链接,可参考 GetOssOriginalUrl 去除 ApiDoc: 七牛云 https://developer.qiniu.com/dora/1269/pictures-basic-information-imageinfo

Jump to

Keyboard shortcuts

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