Commit 0c5ef191 authored by 赵啸非's avatar 赵啸非

添加水印图片

parent 52992564
package com.mortals.xhx.common.utils; package com.mortals.xhx.common.utils;
import cn.hutool.core.img.Img;
import com.mortals.xhx.module.record.web.ApplyLogController; import com.mortals.xhx.module.record.web.ApplyLogController;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails; import net.coobird.thumbnailator.Thumbnails;
...@@ -33,7 +34,10 @@ public class WatermarkImgUtils { ...@@ -33,7 +34,10 @@ public class WatermarkImgUtils {
BufferedImage read = ImageIO.read(new File(sourceImgPath)); BufferedImage read = ImageIO.read(new File(sourceImgPath));
BufferedImage bi = waterMarkByText(read.getWidth(),read.getHeight(),waterMarkContent,Color.RED, BufferedImage bi = waterMarkByText(read.getWidth(),read.getHeight(),waterMarkContent,Color.RED,
new Font("宋体", Font.BOLD, 100),45.0,0.3f,sourceImgPath); new Font("宋体", Font.BOLD, 100),45.0,0.3f,sourceImgPath);
ImageIO.write(bi, fileExt, new File(tarImgPath));
Img.from(bi).write(new File(tarImgPath));
// ImageIO.write(bi, "jpg", new File(tarImgPath));
} catch (IOException e) { } catch (IOException e) {
log.error("添加水印失败",e); log.error("添加水印失败",e);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment