package com.ruoyi.file.utils;
|
|
import cn.hutool.core.img.ImgUtil;
|
|
import java.awt.*;
|
import java.io.*;
|
|
|
public class ImgUtils {
|
|
|
/**
|
* 使用hutool 工具类
|
*/
|
public void SyntheticImages2(File codeImage,File backImage) throws FileNotFoundException {
|
// 生成的二维码
|
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
// QrCodeUtil.generate("https://hutool.cn/", 516, 516, ImgUtil.IMAGE_TYPE_JPG, outputStream);
|
|
// 要输出的图片
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
InputStream codeStream = new FileInputStream(codeImage);
|
InputStream backStream = new FileInputStream(backImage);
|
// 将图片合成在一起
|
ImgUtil.pressImage(
|
backStream, // 主图片
|
out, // 输出图片
|
ImgUtil.read(codeStream).getScaledInstance(516, 516, Image.SCALE_DEFAULT), //水印图片
|
0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
0, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
1.0f
|
);
|
InputStream inputStream = new ByteArrayInputStream(out.toByteArray());
|
|
}
|
}
|