不等比缩放

This commit is contained in:
2024-05-27 18:07:33 +08:00
parent eda92b3f0b
commit 76618de386
8 changed files with 47 additions and 16 deletions

View File

@@ -12,16 +12,16 @@ public class MQConfig {
// public static final String GENERATE_QUEUE = "generate-queue-test"; // public static final String GENERATE_QUEUE = "generate-queue-test";
// ================================================================== // ==================================================================
// public static final String GENERATE_QUEUE = "generate-queue-local"; // public static final String GENERATE_QUEUE = "generate-queue-local";
public static final String GENERATE_QUEUE = "generate-queue-prod"; public static final String GENERATE_QUEUE = "generate-queue-dev";
// public static final String SR_QUEUE = "SR-queue-local"; // public static final String SR_QUEUE = "SR-queue-local";
public static final String SR_QUEUE = "SR-queue-prod"; public static final String SR_QUEUE = "SR-queue-dev";
// public static final String SR_RESULT_QUEUE = "SuperResolution-local"; // public static final String SR_RESULT_QUEUE = "SuperResolution-local";
public static final String SR_RESULT_QUEUE = "SuperResolution-prod"; public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local"; // public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod"; public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
public MQConfig() { public MQConfig() {
} }

View File

@@ -44,7 +44,7 @@ public class DesignSingleItemDTO implements Serializable {
private List<Long> offset; private List<Long> offset;
@ApiModelProperty("图层缩放比例") @ApiModelProperty("图层缩放比例")
private Float scale; private Float[] scale;
@NotNull(message = "priority.cannot.be.empty") @NotNull(message = "priority.cannot.be.empty")
@ApiModelProperty("图层优先级") @ApiModelProperty("图层优先级")

View File

@@ -23,7 +23,7 @@ public class DesignPythonOutfitVO {
private String imageCategory; private String imageCategory;
/** /**
* 图层大小 * 图层大小(前后片大小)
*/ */
@ApiModelProperty(value = "图层大小") @ApiModelProperty(value = "图层大小")
private List<Long> imageSize; private List<Long> imageSize;
@@ -55,7 +55,7 @@ public class DesignPythonOutfitVO {
* 图层缩放比例 * 图层缩放比例
*/ */
@ApiModelProperty(value = "缩放比例") @ApiModelProperty(value = "缩放比例")
private Float scale = 1.0f; private Float[] scale = new Float[]{1.0f,1.0f};
/** /**
* 图层优先级 从10开始优先级数字越大越靠近上层 * 图层优先级 从10开始优先级数字越大越靠近上层
*/ */

View File

@@ -72,7 +72,7 @@ public class DesignPythonItem {
/** /**
* 图层缩放大小 * 图层缩放大小
*/ */
private Float resize_scale; private Float[] resize_scale;
/** /**
* 图层优先级 * 图层优先级
*/ */
@@ -114,7 +114,7 @@ public class DesignPythonItem {
} }
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId,
Long image_id, List<Long> offset, Float resize_scale, Integer priority, String gradient, String gradientString) { Long image_id, List<Long> offset, Float[] resize_scale, Integer priority, String gradient, String gradientString) {
this.type = type; this.type = type;
this.path = path; this.path = path;
this.color = color; this.color = color;

View File

@@ -13,7 +13,7 @@ public class OutfitDetailPythonItem {
private List<Long> image_size; private List<Long> image_size;
private Float scale; private Float[] scale;
private String image_url; private String image_url;
@@ -22,7 +22,7 @@ public class OutfitDetailPythonItem {
public OutfitDetailPythonItem() { public OutfitDetailPythonItem() {
} }
public OutfitDetailPythonItem(String image_category, List<Long> position, List<Long> image_size, Float scale, String image_url, String mask_url) { public OutfitDetailPythonItem(String image_category, List<Long> position, List<Long> image_size, Float[] scale, String image_url, String mask_url) {
this.image_category = image_category; this.image_category = image_category;
this.position = position; this.position = position;
this.image_size = image_size; this.image_size = image_size;

View File

@@ -586,7 +586,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemLayer.getLayers().forEach(layer -> { designItemLayer.getLayers().forEach(layer -> {
ArrayList<Long> imageSize = new ArrayList<>(); ArrayList<Long> imageSize = new ArrayList<>();
for (int i = 0; i < layer.getImageSize().size(); i++) { for (int i = 0; i < layer.getImageSize().size(); i++) {
imageSize.add((long) (layer.getImageSize().get(i) * layer.getScale())); // todo check这里的计算是否正确
imageSize.add((long) (layer.getImageSize().get(i) * layer.getScale()[i]));
} }
layer.setImageSize(imageSize); layer.setImageSize(imageSize);
if (!StringUtil.isNullOrEmpty(layer.getImageUrl())) { if (!StringUtil.isNullOrEmpty(layer.getImageUrl())) {

View File

@@ -350,7 +350,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
list.add(1L); list.add(1L);
list.add(1L); list.add(1L);
item.setOffset(list); item.setOffset(list);
item.setResize_scale(1f); item.setResize_scale(new Float[]{1.0f,1.0f});
String path = item.getPath(); String path = item.getPath();
if (StringUtils.isEmpty(path)) { if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path(); String bodyPath = item.getBody_path();
@@ -434,7 +434,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
list.add(1L); list.add(1L);
list.add(1L); list.add(1L);
item.setOffset(list); item.setOffset(list);
item.setResize_scale(1f); item.setResize_scale(new Float[]{1.0f,1.0f});
String path = item.getPath(); String path = item.getPath();
if (StringUtils.isEmpty(path)) { if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path(); String bodyPath = item.getBody_path();
@@ -631,7 +631,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
print.setPath(designItemDetail.getPrintPath()); print.setPath(designItemDetail.getPrintPath());
print.setSingleOrOverall("overall"); print.setSingleOrOverall("overall");
print.setPosition("[0.0,0.0]"); print.setPosition("[0.0,0.0]");
print.setScale(1d); // print.setScale(1d);
// todo mark 将print默认scale置为0.3
print.setScale(0.3d);
print.setAngle(0.0); print.setAngle(0.0);
print.setPriority(1); print.setPriority(1);
print.setCreateDate(LocalDateTime.now()); print.setCreateDate(LocalDateTime.now());

View File

@@ -61,7 +61,8 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
designPythonOutfitVO.setImageMinioUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : detail.getImageUrl()); designPythonOutfitVO.setImageMinioUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : detail.getImageUrl());
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(detail.getMaskUrl(), 24 * 60)); designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(detail.getMaskUrl(), 24 * 60));
designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl()); designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl());
designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale())); // designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
designPythonOutfitVO.setScale(modifyScale(detail.getScale()));
designPythonOutfitVO.setOffset(StringUtil.isNullOrEmpty(detail.getOffset()) ? Arrays.asList(0L, 0L) : (List<Long>) JSON.parse(detail.getOffset())); designPythonOutfitVO.setOffset(StringUtil.isNullOrEmpty(detail.getOffset()) ? Arrays.asList(0L, 0L) : (List<Long>) JSON.parse(detail.getOffset()));
designPythonOutfitVO.setPriority(Math.abs(detail.getPriority())); designPythonOutfitVO.setPriority(Math.abs(detail.getPriority()));
// designPythonOutfitVO.setOffset(CollectionUtil.isEmpty(offset) ? Arrays.asList(0L, 0L) : offset); // designPythonOutfitVO.setOffset(CollectionUtil.isEmpty(offset) ? Arrays.asList(0L, 0L) : offset);
@@ -77,6 +78,33 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
return designPythonOutfitVO; return designPythonOutfitVO;
} }
private Float[] modifyScale(String scale){
Float[] scaleFloat = new Float[2];
if (!StringUtil.isNullOrEmpty(scale)){
if (scale.startsWith("[")){
// 去除中括号并去掉多余的空格
scale = scale.trim().replaceAll("^\\[|\\]$", "");
// 根据逗号和可选的空格拆分字符串
String[] parts = scale.split("\\s*,\\s*");
// Float[] floatArray = new Float[parts.length];
// 转换每个字符串为 Float 并添加到数组中
for (int i = 0; i < parts.length; i++) {
try {
scaleFloat[i] = Float.parseFloat(parts[i]);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + parts[i]);
return new Float[0]; // 返回一个空数组或者其他错误处理逻辑
}
}
}else {
scaleFloat = new Float[]{Float.parseFloat(scale),Float.parseFloat(scale)};
}
}
return scaleFloat;
}
@Override @Override
public void deleteByDesignPythonOutfitId(Long designPythonOutfitId) { public void deleteByDesignPythonOutfitId(Long designPythonOutfitId) {
// QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>(); // QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();