images

package
v0.0.0-...-05c6761 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressSingleImage

func CompressSingleImage(imageBytes []byte) ([]byte, error)

CompressSingleImage 接收一个图片的 []byte 数据,并根据设定阈值返回压缩后的数据或原始数据。

func ProcessImages

func ProcessImages(imageData []io.Reader, compressor *Compressor) ([][]byte, error)

func RandomString

func RandomString(length int) string

RandomString 生成指定长度的随机字符串

func UploadBase64ImageToServer

func UploadBase64ImageToServer(base64Image string) (string, error)

将base64图片通过lotus转换成url

func UploadBase64RecordToServer

func UploadBase64RecordToServer(base64Image string) (string, error)

将base64语音通过lotus转换成url

func UploadImage

func UploadImage(filePath, token string, baseurl string) (string, error)

UploadImage 函数上传图片并返回图片URL

func UploadImageBase64

func UploadImageBase64(base64String, token string, baseurl string) (string, error)

UploadImageBase64 函数上传Base64编码的图片并返回图片URL

func UploadRecordBase64

func UploadRecordBase64(base64String, token string, baseurl string) (string, error)

UploadRecordBase64 函数上传Base64编码的音频并返回URL

Types

type Compressor

type Compressor struct {
	QualityStep int // Quality adjustment step
	MinQuality  int // Minimum quality
	MaxQuality  int // Maximum quality
	ThresholdKB int // Size threshold in KB
}

func NewCompressor

func NewCompressor(thresholdKB, qualityStep, minQuality, maxQuality int) *Compressor

func (*Compressor) CompressImage

func (c *Compressor) CompressImage(imageData io.Reader) ([]byte, error)

CompressImage handles image compression based on format.

type ImageUploadResponse

type ImageUploadResponse struct {
	Data struct {
		URL string `json:"url"`
	} `json:"data"`
}

ImageUploadResponse 用于解析上传后的响应

Jump to

Keyboard shortcuts

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