简化考试签名照片处理逻辑

dev
zhangyue 2026-03-09 08:59:35 +08:00
parent 3463ad5390
commit e70ac90cf4
1 changed files with 24 additions and 22 deletions

View File

@ -272,28 +272,30 @@ public class ArchivesQueryExe {
if (!ObjectUtils.isEmpty(params.getExamSignFlag())) {
String imageUrl = fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl();
try (InputStream is = new URL(imageUrl).openStream()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Thumbnailator 自动处理 EXIF 方向,并缩放到 100x100保持比例
Thumbnails.of(is)
.keepAspectRatio(true) // 可选:保持比例,避免拉伸
.outputFormat("JPEG")
.toOutputStream(baos);
byte[] imageBytes = baos.toByteArray();
ByteArrayInputStream bis = new ByteArrayInputStream(imageBytes);
PictureRenderData picture = Pictures.ofStream(bis)
.size(100, 100)
.create();
workItem.put("examSignFacePicture", picture);
} catch (Exception e) {
e.printStackTrace();
// 可选:插入默认占位图
// workItem.put("examSignFacePicture", defaultPicture);
}
PictureRenderData examSignFacePicture = Pictures.ofUrl(fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl(), PictureType.JPEG).size(100, 100).create();//网络图片地址
workItem.put("examSignFacePicture", examSignFacePicture);
// String imageUrl = fileUrlConfig.getPrefixUrl() + params.getExamSignFaceUrl();
// try (InputStream is = new URL(imageUrl).openStream()) {
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
//
// // Thumbnailator 自动处理 EXIF 方向,并缩放到 100x100保持比例
// Thumbnails.of(is)
// .keepAspectRatio(true) // 可选:保持比例,避免拉伸
// .outputFormat("JPEG")
// .toOutputStream(baos);
//
// byte[] imageBytes = baos.toByteArray();
// ByteArrayInputStream bis = new ByteArrayInputStream(imageBytes);
// PictureRenderData picture = Pictures.ofStream(bis)
// .size(100, 100)
// .create();
//
// workItem.put("examSignFacePicture", picture);
// } catch (Exception e) {
// e.printStackTrace();
// // 可选:插入默认占位图
// // workItem.put("examSignFacePicture", defaultPicture);
// }
}
String templatePath = "templates/template/studyRecord.docx";