From f67c6aa89564a9b7b3ed0e0cc8c06d930162baa4 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: Fri, 22 Sep 2023 13:55:11 +0800
Subject: [PATCH] 增加jar包和依赖包分离
---
/dev/null | 241 ------------------------------------------------
ruoyi-admin/pom.xml | 33 ++++++
2 files changed, 33 insertions(+), 241 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/utils/image/WaterMarkUtil.java b/ard-work/src/main/java/com/ruoyi/utils/image/WaterMarkUtil.java
deleted file mode 100644
index 14a4b1f..0000000
--- a/ard-work/src/main/java/com/ruoyi/utils/image/WaterMarkUtil.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package com.ruoyi.utils.image;
-
-import org.bytedeco.ffmpeg.global.avutil;
-import org.bytedeco.javacv.FFmpegFrameGrabber;
-import org.bytedeco.javacv.FFmpegFrameRecorder;
-import org.bytedeco.javacv.Frame;
-import org.bytedeco.javacv.Java2DFrameUtils;
-import org.bytedeco.opencv.opencv_core.IplImage;
-import javax.imageio.ImageIO;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.awt.*;
-import java.awt.image.BufferedImage;
-/**
- * @ClassName WaterMarkUtil
- * @Description:
- * @Author 刘苏义
- * @Date 2023/1/17 20:20
- * @Version 1.0
- */
-
-
-/**
- * 图片水印工具类
- */
-public class WaterMarkUtil {
-
- // 水印透明度
- private static final float alpha = 0.3f;
- // 水印横向位置
- private static int positionWidth = 500;
- // 水印纵向位置
- private static int positionHeight = 500;
- // 水印文字字体
- private static final Font font = new Font("微软雅黑", Font.BOLD, 80);
- // 水印文字颜色
- private static final Color color = Color.blue;
-
- /**
- * 给图片添加水印文字
- *
- * @param text 水印文字
- * @param srcImgPath 源图片路径
- * @param targetPath 目标图片路径
- */
- public static void markImage(String text, String srcImgPath, String targetPath) {
- markImage(text, srcImgPath, targetPath, null);
- }
-
- /**
- * 给图片添加水印文字、可设置水印文字的旋转角度
- *
- * @param text
- * @param srcImgPath
- * @param targetPath
- * @param degree
- */
- public static void markImage(String text, String srcImgPath, String targetPath, Integer degree) {
-
- OutputStream os = null;
- try {
- // 0、图片类型
- String type = srcImgPath.substring(srcImgPath.indexOf(".") + 1, srcImgPath.length());
-
- // 1、源图片
- Image srcImg = ImageIO.read(new File(srcImgPath));
-
- int imgWidth = srcImg.getWidth(null);
- int imgHeight = srcImg.getHeight(null);
-
- BufferedImage buffImg = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);
-
- // 2、得到画笔对象
- Graphics2D g = buffImg.createGraphics();
- // 3、设置对线段的锯齿状边缘处理
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.drawImage(srcImg.getScaledInstance(imgWidth, imgHeight, Image.SCALE_SMOOTH), 0, 0, null);
- // 4、设置水印旋转
- if (null != degree) {
- g.rotate(Math.toRadians(degree), (double) buffImg.getWidth() / 2, (double) buffImg.getHeight() / 2);
- }
- // 5、设置水印文字颜色
- g.setColor(color);
- // 6、设置水印文字Font
- g.setFont(font);
- // 7、设置水印文字透明度
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
- // 8、第一参数->设置的内容,后面两个参数->文字在图片上的坐标位置(x,y)
- positionWidth = 50;
- positionHeight = imgHeight - 30;
- g.drawString(text, positionWidth, positionHeight);
- // 9、释放资源
- g.dispose();
- // 10、生成图片
- os = new FileOutputStream(targetPath);
- // ImageIO.write(buffImg, "JPG", os);
- ImageIO.write(buffImg, type.toUpperCase(), os);
-
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (null != os) {
- os.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * 给图片添加水印文字、可设置水印文字的旋转角度
- *
- * @param text
- * @param inputStream
- * @param outputStream
- * @param degree
- * @param typeName
- */
- public static void markImageByIO(String text, InputStream inputStream, OutputStream outputStream,
- Integer degree, String typeName) {
- try {
- // 1、源图片
- Image srcImg = ImageIO.read(inputStream);
-
- int imgWidth = srcImg.getWidth(null);
- int imgHeight = srcImg.getHeight(null);
- BufferedImage buffImg = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);
-
- // 2、得到画笔对象
- Graphics2D g = buffImg.createGraphics();
- // 3、设置对线段的锯齿状边缘处理
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.drawImage(srcImg.getScaledInstance(imgWidth, imgHeight, Image.SCALE_SMOOTH), 0, 0, null);
- // 4、设置水印旋转
- if (null != degree) {
- g.rotate(Math.toRadians(degree), (double) buffImg.getWidth() / 2, (double) buffImg.getHeight() / 2);
- }
- // 5、设置水印文字颜色
- g.setColor(color);
- // 6、设置水印文字Font
- g.setFont(font);
- // 7、设置水印文字透明度
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
- // 8、第一参数->设置的内容,后面两个参数->文字在图片上的坐标位置(x,y)
-
- g.drawString(text, positionWidth, positionHeight);
- // 9、释放资源
- g.dispose();
- // 10、生成图片
- ImageIO.write(buffImg, typeName.toUpperCase(), outputStream);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void markVideo(String text, String srcImgPath, String targetPath) {
- avutil.av_log_set_level(avutil.AV_LOG_ERROR);
- File file = new File(srcImgPath);
- //抓取视频资源
- FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(file);
- //
- Frame frame = null;
- FFmpegFrameRecorder recorder = null;
- // String fileName = null;
- try {
- frameGrabber.start();
- //Random random = new Random();
-// fileName = file.getAbsolutePath() + random.nextInt(100)+".mp4";
-// System.out.println("文件名-->>"+fileName);
- frameGrabber.setFrameRate(25); // 设置每秒处理10帧
- recorder = new FFmpegFrameRecorder(targetPath, frameGrabber.getImageWidth(), frameGrabber.getImageHeight(), frameGrabber.getAudioChannels());
- //recorder.setFormat("mp4");
- recorder.setSampleRate(frameGrabber.getSampleRate());
- recorder.setFrameRate( frameGrabber.getFrameRate());
- recorder.setTimestamp(frameGrabber.getTimestamp());
- recorder.setVideoBitrate(frameGrabber.getVideoBitrate());
- recorder.setVideoCodec(frameGrabber.getVideoCodec());
- recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
-
- recorder.start();
- int index = 0;
- while (true) {
- frame = frameGrabber.grabFrame();
- if (frame == null) {
- System.out.println("视频处理完成");
- break;
- }
- //判断音频
- // System.out.println("音频==" + (frame.samples == null) + "视频==" + (frame.image == null));
- //判断图片帧
- if (frame.image != null) {
- IplImage iplImage = Java2DFrameUtils.toIplImage(frame);
- BufferedImage buffImg = Java2DFrameUtils.toBufferedImage(iplImage);
- Graphics2D graphics = buffImg.createGraphics();
- graphics.setColor(color);
- graphics.setFont(font);
- // 设置透明度
- float alpha = 0.5f; // 设置透明度值,范围为 0.0(完全透明)到 1.0(完全不透明)
- AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
- graphics.setComposite(alphaComposite);
- graphics.drawString(text, positionWidth, positionHeight);
- graphics.dispose();
- Frame newFrame = Java2DFrameUtils.toFrame(buffImg);
- recorder.record(newFrame);
- }
- //设置音频
-// if (frame.samples != null) {
-// recorder.recordSamples(frame.sampleRate, frame.audioChannels, frame.samples);
-// }
- // System.out.println("帧值=" + index);
- index++;
- }
-
- recorder.stop();
- recorder.release();
- frameGrabber.stop();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- public static void main(String[] args) {
-// String srcImgPath = "G:\\data\\pic\\7aad76110e7c478598da6b82d7446246.jpeg";
-// String text = "synjones";
-// // 给图片添加水印文字
-// //markImage(text, srcImgPath, "G:\\data\\pic\\微信截图水印.png");
-// // 给图片添加水印文字,水印文字旋转-45
-// markImage(text, srcImgPath, "G:\\data\\pic\\7aad76110e7c478598da6b82d7446246水印.png", 45);
-// System.out.println("给图片添加水印文字完毕");
-
- String videoPath="D:\\1.mp4";
- markVideo("安瑞达科技",videoPath,"D:\\2.mp4");
- System.out.println("给视频添加水印文字完毕");
- }
-}
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index 440b99a..dd16999 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -71,12 +71,45 @@
<build>
<plugins>
+ <!-- ==================== 依赖jar 优化start ========================== -->
+ <!-- lib包,打完一次后可以注释掉也可以不管,如果有新引入的jar包需要把lib包下的jar更新到服务器下,
+ // 压缩后jar包的启动指令 java -Dloader.path="lib/" -jar xxx.jar
+ // 未压缩jar包的启动指令 java -jar xxx.jar"
+ -->
+<!-- <plugin>-->
+<!-- <groupId>org.apache.maven.plugins</groupId>-->
+<!-- <artifactId>maven-dependency-plugin</artifactId>-->
+<!-- <executions>-->
+<!-- <execution>-->
+<!-- <id>copy-dependencies</id>-->
+<!-- <phase>package</phase>-->
+<!-- <goals>-->
+<!-- <goal>copy-dependencies</goal>-->
+<!-- </goals>-->
+<!-- <configuration>-->
+<!-- <!– 依赖包输出目录,将来不打进jar包里 –>-->
+<!-- <outputDirectory>${project.build.directory}/jarLib</outputDirectory>-->
+<!-- <excludeTransitive>false</excludeTransitive>-->
+<!-- <stripVersion>false</stripVersion>-->
+<!-- <includeScope>runtime</includeScope>-->
+<!-- </configuration>-->
+<!-- </execution>-->
+<!-- </executions>-->
+<!-- </plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<configuration>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
+ <mainClass>com.ruoyi.RuoYiApplication</mainClass>
+ <layout>ZIP</layout>
+ <includes>
+ <include>
+ <groupId>nothing</groupId>
+ <artifactId>nothing</artifactId>
+ </include>
+ </includes>
</configuration>
<executions>
<execution>
--
Gitblit v1.9.3