Package tech.mgl.core.utils.img
Class MGL_ImageUtils
java.lang.Object
tech.mgl.core.utils.img.MGL_ImageUtils
ClassName: ImageUtils
- Author:
- hotpot https://mgl.tech
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean合并图片static boolean图片裁剪static voiddownloadImage(String imageUrl, String savePath) 下载网络图片到本地static byte[]fetchNetImg(String url) 从网络获取图片字节数组static BufferedImagegetTransparentImg(int width, int height) 获取一张透明图static booleanstatic booleanstatic booleanstatic voidstatic BufferedImagerotateImage(String srcPath, String destPath, int angel) 旋转图片,如果PNG图片旋转后背景是透明背景static BufferedImagerotateImage(String srcPath, String destPath, int angel, boolean setTran) 旋转图片,如果输入的是是JPG图片,当输出格式PNG并setTran=true时输出背景为透明
-
Constructor Details
-
MGL_ImageUtils
public MGL_ImageUtils()
-
-
Method Details
-
cropImage
public static boolean cropImage(String src, String dest, int x, int y, int w, int h) throws IOException 图片裁剪- Parameters:
src- 原图dest- 目标图x- 起始Xy- 起始Yw- 剪切宽度h- 剪切高度- Returns:
- boolean 返回类型
- Throws:
IOException- 参数
-
rotateImage
public static BufferedImage rotateImage(String srcPath, String destPath, int angel) throws IOException 旋转图片,如果PNG图片旋转后背景是透明背景- Parameters:
srcPath- 原destPath- 目angel- 角度- Returns:
- BufferedImage 返回类型
- Throws:
IOException- 参数
-
rotateImage
public static BufferedImage rotateImage(String srcPath, String destPath, int angel, boolean setTran) throws IOException 旋转图片,如果输入的是是JPG图片,当输出格式PNG并setTran=true时输出背景为透明- Parameters:
srcPath-destPath-angel-setTran-- Returns:
- Throws:
IOException- 参数
-
getTransparentImg
获取一张透明图- Parameters:
width-height-- Returns:
- 参数
-
append
public static boolean append(List<MGL_ImgVo> inputFileNameList, String outputFileName, int outputW, int outputH) throws Exception 合并图片- Parameters:
inputFileNameList-outputFileName-outputW-outputH-- Returns:
- Throws:
Exception- 参数
-
main
-
isImage
-
isImage
-
isImage
- Throws:
Exception
-
fetchNetImg
从网络获取图片字节数组- Parameters:
url- 图片的网络地址- Returns:
- 图片的字节数组,如果获取失败则抛出异常
- Throws:
IOException- 如果网络请求失败或响应状态异常
-
downloadImage
下载网络图片到本地- Parameters:
imageUrl- 网络图片URLsavePath- 本地保存路径(包含文件名)- Throws:
IOException- 如果下载失败则抛出异常InterruptedException- 如果请求被中断
-