refactor(encoder): optimize extra image processing parameters handling

This commit is contained in:
wood chen 2024-10-23 07:23:39 +08:00
parent ffa5242983
commit e11cd575c8

View File

@ -216,13 +216,18 @@ func preProcessImage(img *vips.ImageRef, imageType string, extraParams config.Ex
// 额外参数处理 // 额外参数处理
if config.Config.EnableExtraParams { if config.Config.EnableExtraParams {
log.Debug("开始应用额外图像处理参数") // 检查是否需要进行尺寸调整
if err := resizeImage(img, extraParams); err != nil { if extraParams.MaxWidth != 0 || extraParams.MaxHeight != 0 || extraParams.Width != 0 || extraParams.Height != 0 {
log.Errorf("应用额外图像处理参数失败: %v", err) log.Debug("开始应用额外图像处理参数")
// 这里不设置 shouldCopyOriginal 为 true因为我们不想在这种情况下复制原图 if err := resizeImage(img, extraParams); err != nil {
return shouldCopyOriginal, err log.Errorf("应用额外图像处理参数失败: %v", err)
// 这里不设置 shouldCopyOriginal 为 true因为我们不想在这种情况下复制原图
return shouldCopyOriginal, err
}
log.Debug("额外图像处理参数应用完成")
} else {
log.Debug("未设置任何尺寸参数,跳过图像尺寸调整")
} }
log.Debug("额外图像处理参数应用完成")
} }
log.Debug("图像预处理完成") log.Debug("图像预处理完成")