7764次浏览
我们通过java把下面的背景图和二维码以及文字“java菜市场-专注于技术干货的免费分享”合并成一张新的图片背景图片二维码图片public class Main {
/**
* 合成图片
*
* @param backgroundPath
* @param qrCodePath
* @param message
* @param outPutPath
* @throws IOException
*/
public static void overlapImage(String backgroundPath, String qrCodePath, String message, String outPutPath) throws IOException {
// 设置背景图片大小
BufferedImage backgroundImage = resizeImage(566, 230, ImageIO.read(new File(backgroundPat
6509次浏览
Thumbnailator,一款google使用的开源的图片压缩工具类。github地址:https://github.com/coobird/thumbnailator优点:1、压缩程度可控制,想压缩成多小就多小。2、压缩之后图片尽可能的不失真。3、压缩速度要快。4、代码简单,依赖较少。5、可以实现对图片到编辑,如如旋转,裁切,加水印等等。使用方法:添加maven依赖 <dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>使用起来也很简单,一行代码搞定: Thumbnails.of("原图文件的路径") .scale(1f) .outputQuality(0.5f) .toFile("压缩