fix:图片裁剪

This commit is contained in:
Hiven
2023-08-18 17:38:12 +08:00
parent 60e4713806
commit fa97e20ae1
7 changed files with 156 additions and 3 deletions

View File

@@ -250,6 +250,7 @@ type (
/* 图片裁剪 */
func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) {
var resourceId string = hash.JsonHashKey(in)
var postMap = make(map[string]interface{}, 2)
postMap["is_remove_bg"] = in.IsRemoveBg
postMap["logo_file"] = in.LogoFile
@@ -305,7 +306,37 @@ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardR
}
//$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}'
return nil, nil
var fileBase = resultData["nobg_url"].(string)
var ismaxProportion = resultData["ismax_proportion"].(bool)
var imgColor []string
for _, v := range resultData["img_color"].([]interface{}) {
imgColor = append(imgColor, v.(string))
}
// 上传文件
var upload = file.Upload{
Ctx: ctx,
MysqlConn: l.MysqlConn,
AwsSession: l.AwsSession,
}
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
Source: "combine-removebg",
FileHash: resourceId,
FileData: fileBase,
UploadBucket: 1,
ApiType: 2,
})
if err != nil {
logx.Error(err)
return nil, err
}
return &LogoStandardRes{
ResourceId: uploadRes.ResourceId,
ResourceUrl: uploadRes.ResourceUrl,
IsmaxProportion: ismaxProportion,
ImgColor: imgColor,
}, nil
}
/* 图片裁剪 */