/** * 生成二维码(内嵌LOGO) * * @param content 内容 * @param imgPath LOGO地址 * @param destPath 存放目录 * @param needCompress 是否压缩LOGO * @throws Exception */ public static File encode( String content, String imgPath, String destPath, boolean needCompress, QRCodeConfig qrCodeConfig) throws Exception { BufferedImage image = QRCodeUtil.createImage(content, imgPath, needCompress, qrCodeConfig); mkdirs(destPath); String fileName = null; if (qrCodeConfig != null && qrCodeConfig.getFileName() != null) { fileName = qrCodeConfig.getFileName() + ".png"; } else { fileName = new Random().nextInt(99999999) + ".png"; } File file = new File(destPath + File.separator + fileName); ImageIO.write(image, FORMAT_NAME, file); return file; }