fix:由于ai返回的图片为png,在此支持png格式
This commit is contained in:
@@ -231,13 +231,25 @@ public class TryOnEffectServiceImpl extends ServiceImpl<TryOnEffectMapper, TryOn
|
|||||||
int startIndex = tryonUrl.indexOf("lanecarford");
|
int startIndex = tryonUrl.indexOf("lanecarford");
|
||||||
String aiRreultlogicalUrl = "";
|
String aiRreultlogicalUrl = "";
|
||||||
if (startIndex != -1) {
|
if (startIndex != -1) {
|
||||||
// 找到jpg的位置并加上jpg的长度
|
// 支持jpg和png格式的图片识别
|
||||||
int endIndex = tryonUrl.indexOf(".jpg") + ".jpg".length();
|
int jpgEndIndex = tryonUrl.indexOf(".jpg");
|
||||||
|
int pngEndIndex = tryonUrl.indexOf(".png");
|
||||||
|
|
||||||
|
int endIndex = -1;
|
||||||
|
|
||||||
|
if (jpgEndIndex != -1 && (pngEndIndex == -1 || jpgEndIndex < pngEndIndex)) {
|
||||||
|
// 找到jpg格式
|
||||||
|
endIndex = jpgEndIndex + ".jpg".length();
|
||||||
|
} else if (pngEndIndex != -1 && (jpgEndIndex == -1 || pngEndIndex < jpgEndIndex)) {
|
||||||
|
// 找到png格式
|
||||||
|
endIndex = pngEndIndex + ".png".length();
|
||||||
|
}
|
||||||
|
|
||||||
if (endIndex != -1) {
|
if (endIndex != -1) {
|
||||||
String resultString = tryonUrl.substring(startIndex, endIndex);
|
String resultString = tryonUrl.substring(startIndex, endIndex);
|
||||||
aiRreultlogicalUrl = AITryOnEffect(prompt, Arrays.asList(resultString));
|
aiRreultlogicalUrl = AITryOnEffect(prompt, Arrays.asList(resultString));
|
||||||
} else {
|
} else {
|
||||||
log.error("不是换脸后的url或者换脸结果有误");
|
log.error("未找到jpg或png格式的图片,无法识别图片类型");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
|
return minioUtil.convertToPresignedUrl(aiRreultlogicalUrl, CommonConstants.MINIO_PATH_TIMEOUT);
|
||||||
|
|||||||
Reference in New Issue
Block a user