Thank you very much for your answer,Below is my related code.
Load psd file code
// opening Psd Image
String psdPath = FilenameUtils.concat(fileProcessor.getPsdDir(), templateUrl);
// InputStream inputStream = fileProcessor.getPsdInputStreamByUrl(templateUrl);
try (PsdImage templateFile = (PsdImage) PsdImage.load(psdPath)) {
log.info("Load MockupTemplate {} to PsdImage, cost {} ms", psdPath, System.currentTimeMillis() - start);
Map<String, LayerPlaceholder> layerPlaceholderMap = toMap(layerPlaceholders);
Map<String, LayerProcessParams> layerProcessParamsMap = toMap(layerProcessParams);
start = System.currentTimeMillis();
process(templateFile, layerPlaceholderMap, layerProcessParamsMap);
log.info("process MockupTemplate, cost {} ms", System.currentTimeMillis() - start);
FileUploadJsonResponse result = output(templateFile, request);
response.setFileUrl(result.getData().getUrl());
response.setFormat(result.getData().getFormat());
response.setFileName(result.getData().getFileName());
} catch (Exception e) {
throw BusinessExceptionBuilder.of(610004, ImmutableMap.of("templateUrl", psdPath, "message", e.getMessage()));
}
code of loading image for the replacement
SmartObjectLayer layer = LayerPlaceholderProcessor.obtainLayer(template, spec.getCode(), SmartObjectLayer.class);
byte[] imageBytes;
String defaultFileType = commonPropertiesService.getKeyValueAndApplicationModeForNoException(FileProcessor.DEFAULT_FILE_TYPE_KEY);
String fileType = StringUtils.isBlank(defaultFileType) ? "jpg" : defaultFileType;
try {
List<ImagePipeline> imagePipeline = params.getImagePipeline();
if (CollectionUtils.isNotEmpty(imagePipeline)) {
ByteInfo byteInfo = buildPipeline(params);
imageBytes = byteInfo.getBytes();
fileType = byteInfo.getFormat();
} else {
if (fileProcessor.isImage(params.getImageUrl())) {
fileType = FilenameUtils.getExtension(params.getImageUrl());
}
imageBytes = fileProcessor.getBytesByUrl(params.getImageUrl(), fileType);
}
} catch (IOException e) {
throw BusinessExceptionBuilder.of(610003, ImmutableMap.of("layerCode", params.getCode(), "imageUrl", params.getImageUrl(), "message", e.getMessage()));
}
if (imageBytes != null && imageBytes.length > 0) {
LinkDataSource contentsSource = layer.getContentsSource();
contentsSource.setFileType(fileType);
layer.setContents(imageBytes);
layer.updateModifiedContent();
}
when my code run in
layer.updateModifiedContent();
I find the SmartObjectLayer`s height and width is change
int height = layer.getHeight();
int width = layer.getWidth();
alse the Pupper Warp size change with the SmartObjectLayer