From f67c6aa89564a9b7b3ed0e0cc8c06d930162baa4 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期五, 22 九月 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銆佽缃按鍗版枃瀛桭ont - 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銆佽缃按鍗版枃瀛桭ont - 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鍖呬笅鐨刯ar鏇存柊鍒版湇鍔″櫒涓嬶紝 + // 鍘嬬缉鍚巎ar鍖呯殑鍚姩鎸囦护 java -Dloader.path="lib/" -jar xxx.jar + // 鏈帇缂﹋ar鍖呯殑鍚姩鎸囦护 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>--> +<!-- <!– 渚濊禆鍖呰緭鍑虹洰褰曪紝灏嗘潵涓嶆墦杩沯ar鍖呴噷 –>--> +<!-- <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