fusenapi/utils/image/image_size.go
laodaming 0b6428cf34 fix
2023-10-12 14:01:23 +08:00

38 lines
834 B
Go

package image
// 定义尺寸规则
var sizeArray = []uint32{1200, 1000, 750, 500, 128}
// 裁剪尺寸阶梯
var newSizeArray = []uint32{200, 400, 600, 800}
// 获取合适尺寸
func GetCurrentSize(clientSize uint32) uint32 {
lenNewSize := len(newSizeArray)
//大于最大尺寸则返回规则最大尺寸
if clientSize >= newSizeArray[lenNewSize-1] {
return newSizeArray[lenNewSize-1]
}
//小于最小尺寸则返回规则最小尺寸
if clientSize <= newSizeArray[0] {
return newSizeArray[0]
}
for _, v := range newSizeArray {
if v >= clientSize {
return v
}
}
return clientSize
}
// 千人前面图像拼接
type ThousandFaceImageFormatReq struct {
Size int
IsThousandFace int
Cover string
CoverImg string
CoverDefault string
ProductId int64
UserId int64
}