简化考试签名照片处理逻辑
parent
3463ad5390
commit
e70ac90cf4
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Reference in New Issue