Java实现对png图片文件电子签名操作

/**
 *  根据图片像素位置添加用户电子签名
 * @param imagePath     要操作的图片路径
 * @param signImagePath 电子签名图片路径
 * @param outImagePath  合成后输出图片路径
 * @param width  像素位宽度
 * @param height 像素位高度
 */
public static void syntheticPicture(String imagePath, String signImagePath,Integer width,Integer height, String outImagePath ) {
    try {
        BufferedImage big = ImageIO.read(new File(imagePath));
        BufferedImage small = ImageIO.read(new File(signImagePath));
        Graphics2D g = big.createGraphics();
        //根据图片像素位置粘贴带电子签名
        g.drawImage(small, width, height, small.getWidth(), small.getHeight(), null);
        g.dispose();
        ImageIO.write(big, outImagePath .split("\\.")[1], new File(outImagePath ));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

猜你喜欢

转载自blog.csdn.net/qq_38114563/article/details/81408211