From 65f3fa7a6e57ceec3eb96858f9be3346830fa829 Mon Sep 17 00:00:00 2001 From: haoxr <1490493387@qq.com> Date: Sun, 5 Mar 2023 14:53:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/youlai/common/util/ImgUtils.java | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 youlai-common/common-core/src/main/java/com/youlai/common/util/ImgUtils.java diff --git a/youlai-common/common-core/src/main/java/com/youlai/common/util/ImgUtils.java b/youlai-common/common-core/src/main/java/com/youlai/common/util/ImgUtils.java deleted file mode 100644 index ff038cc4e..000000000 --- a/youlai-common/common-core/src/main/java/com/youlai/common/util/ImgUtils.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.youlai.common.util; - -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.StrUtil; - -/** - * 文件工具类 - * - * @author - * @date 2022/7/17 - */ -public class ImgUtils { - - private static final String[] imgSuffixArr = {"bmp", "dib", "gif", "jfif", "jpe", "jpeg", "jpg", "png", "tif", "tiff", "ico"}; - - /** - * 是否图片判断 - * - * @param fileName - * @return - */ - public static boolean isImg(String fileName) { - if (StrUtil.isBlank(fileName)) { - return false; - } - - String fileSuffix = FileUtil.getSuffix(fileName); - - for (String imgSuffix : imgSuffixArr) { - if (fileSuffix.equals(imgSuffix)) { - return true; - } - } - return false; - } - - - /** - * 根据图片大小设置压缩比 - * - * @param size 图片大小(单位:Bytes) - * @return 压缩比例 - */ - public static float getCompressQuality(long size) { - if (size > 0.1 * 1024 * 1024 && size <= 0.5 * 1024 * 1024) { - return 0.8f; - } else if (size > 0.5 * 1024 * 1024 && size <= 1 * 1024 * 1024) { - return 0.6f; - } else if (size > 1 * 1024 * 1024 && size <= 2 * 1024 * 1024) { - return 0.4f; - } else if (size > 2 * 1024 * 1024 && size <= 5 * 1024 * 1024) { - return 0.2f; - } else { - // 大于5M - return 0.1f; - } - } -}