Documentation ¶
Index ¶
- func CompressSingleImage(imageBytes []byte) ([]byte, error)
- func ProcessImages(imageData []io.Reader, compressor *Compressor) ([][]byte, error)
- func RandomString(length int) string
- func UploadBase64ImageToServer(base64Image string) (string, error)
- func UploadBase64RecordToServer(base64Image string) (string, error)
- func UploadImage(filePath, token string, baseurl string) (string, error)
- func UploadImageBase64(base64String, token string, baseurl string) (string, error)
- func UploadRecordBase64(base64String, token string, baseurl string) (string, error)
- type Compressor
- type ImageUploadResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressSingleImage ¶
CompressSingleImage 接收一个图片的 []byte 数据,并根据设定阈值返回压缩后的数据或原始数据。
func ProcessImages ¶
func ProcessImages(imageData []io.Reader, compressor *Compressor) ([][]byte, error)
func UploadBase64ImageToServer ¶
将base64图片通过lotus转换成url
func UploadBase64RecordToServer ¶
将base64语音通过lotus转换成url
func UploadImage ¶
UploadImage 函数上传图片并返回图片URL
func UploadImageBase64 ¶
UploadImageBase64 函数上传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 用于解析上传后的响应
Click to show internal directories.
Click to hide internal directories.