|
|
@@ -971,7 +971,7 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
if (StringUtil.isNotBlank(conversation.getImageUrl())) {
|
|
|
log.info("获取到的图片 url:{}", conversation.getImageUrl());
|
|
|
ImgSize imgSize = TASK_IMG_SIZE_MAP.get(conversation.getTaskId());
|
|
|
- URL url = new URL(conversation.getImageUrl());
|
|
|
+ URL url = new URL(conversation.getImageUrl().replace("mj.galaxydvd.com","media.discordapp.net"));
|
|
|
//if(imgSize == null){
|
|
|
// try {
|
|
|
// String filePath = url.getFile();
|
|
|
@@ -1043,9 +1043,21 @@ public class MidjourneyServiceImpl implements MidjourneyService {
|
|
|
}
|
|
|
|
|
|
String scaling = "";
|
|
|
- if(imgSize != null){
|
|
|
- scaling = "quality=lossless&width=" + imgSize.getWidth() + "&height=" + imgSize.getHeight();
|
|
|
- if(url.getFile().contains("webp")){
|
|
|
+
|
|
|
+ if (imgSize != null) {
|
|
|
+ // 如果尺寸大于1024 则按比例缩小到512左右
|
|
|
+ // 获取图片的宽度和高度
|
|
|
+ int width = imgSize.getWidth();
|
|
|
+ int height = imgSize.getHeight();
|
|
|
+
|
|
|
+ // 如果高度大于1024,则按比例缩小到高度512
|
|
|
+ if (height > 1024) {
|
|
|
+ double scalingFactor = 512.0 / height;
|
|
|
+ width = (int) (width * scalingFactor);
|
|
|
+ height = 512;
|
|
|
+ }
|
|
|
+ scaling = "quality=lossless&width=" + width + "&height=" + height;
|
|
|
+ if (url.getFile().contains("webp")) {
|
|
|
scaling += "&format=webp";
|
|
|
}
|
|
|
}
|