You've already forked FrameTour-BE
feat(image): 添加水印缩放功能支持
- 在 WatermarkConfig 中新增 scale 字段用于控制整体缩放倍数 - 在 WatermarkStage 中读取并传递 scale 参数到 WatermarkInfo - 在 PrinterDefaultWatermarkOperator 中实现所有位置和尺寸的缩放逻辑 - 对偏移量、边距、字体大小、二维码尺寸等应用缩放因子 - 更新图像绘制相关参数计算方式以支持动态缩放 - 优化二维码圆形背景和头像绘制的缩放处理 - 确保缩放后的水印元素保持相对位置和视觉一致性
This commit is contained in:
@@ -34,4 +34,11 @@ public class WatermarkConfig {
|
||||
* 二维码文件
|
||||
*/
|
||||
private final File qrcodeFile;
|
||||
|
||||
/**
|
||||
* 缩放倍数,用于将所有定位和大小乘以该倍数
|
||||
* 默认值为 1.0(不缩放)
|
||||
*/
|
||||
@Builder.Default
|
||||
private final Double scale = 1.0;
|
||||
}
|
||||
|
||||
@@ -170,6 +170,12 @@ public class WatermarkStage extends AbstractPipelineStage<PhotoProcessContext> {
|
||||
info.setQrcodeFile(qrcodeFile);
|
||||
}
|
||||
|
||||
// 从 config 读取缩放倍数
|
||||
Double scale = config.getScale();
|
||||
if (scale != null) {
|
||||
info.setScale(scale);
|
||||
}
|
||||
|
||||
// 根据旋转状态自己处理 offsetLeft
|
||||
if (context.isRotationApplied()) {
|
||||
if (context.getImageRotation() == 90) {
|
||||
|
||||
Reference in New Issue
Block a user