public final class ImageUtils extends Object
| 构造器和说明 |
|---|
ImageUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
cutImage(byte[] imageBytes,
int x,
int y,
int cutWidth,
int cutHeight)
裁切图片
|
static byte[] |
cutImage(File imageFile,
int x,
int y,
int cutWidth,
int cutHeight)
裁切图片
|
static String |
getImageFormat(byte[] image)
获取图片格式
|
static String |
getImageFormat(File image)
获取图片格式
|
static int[] |
getImageWH(byte[] bytes)
获取图片的宽和高
|
static int[] |
getImageWH(File imageFile)
获取图片的宽和高
|
static void |
resizeAddLogoSave(InputStream srcImage,
InputStream waterImage,
int maxImgWidth,
float alpha,
int pointX,
int pointY,
Integer degree,
String targetPath)
给图片添加水印、可设置水印图片旋转角度
|
static void |
resizeAddLogoWrite(InputStream inputStream,
String logoText,
int maxImgWidth,
Color fontColor,
String fontName,
int fontSize,
float alpha,
int pointX,
int pointY,
Integer degree,
String targetPath)
重设图片文件大小并设置水印后保存
|
static byte[] |
resizeByMaxSize(byte[] bytes,
int maxSize)
按指定的最大值缩放,以Math.max(width,height)为准
|
static byte[] |
resizeByMaxSize(File srcFile,
int maxSize)
按指定的最大值缩放,以Math.max(width,height)为准
|
static byte[] |
resizeCutImage(byte[] bytes,
int cutWidth,
int cutHeight)
缩放后按指定宽、高裁切图片
|
static byte[] |
resizeCutImage(File srcFile,
int cutWidth,
int cutHeight)
缩放后按指定宽、高裁切图片
|
static void |
resizeCutWriteImage(byte[] bytes,
int newWidth,
int newHeight,
File targetFile)
按指定的宽度、高度重设图片大小后保存
|
static void |
resizeCutWriteImage(File srcFile,
int newWidth,
int newHeight,
File targetFile)
按指定的宽度、高度重设图片大小后保存
|
static byte[] |
resizeImage(byte[] bytes,
int newWidth,
int newHeight)
按指定的宽度、高度重设图片大小后保存
|
static byte[] |
resizeImage(File srcFile,
int newWidth,
int newHeight)
按指定的宽度、高度重设图片大小后保存
|
static byte[] |
resizeImageByWidth(byte[] bytes,
int newWith)
根据宽度按比例缩放
|
static byte[] |
resizeImageByWidth(File srcFile,
int newWith)
根据宽度按比例缩放
|
static void |
resizeWriteByMaxSize(byte[] bytes,
int maxSize,
File targetFile)
按指定的最大值缩放,以Math.max(width,height)为准
|
static void |
resizeWriteByMaxSize(File srcFile,
int maxSize,
File targetFile)
按指定的最大值缩放,以Math.max(width,height)为准
|
static void |
resizeWriteImage(byte[] bytes,
int newWidth,
int newHeight,
File targetFile)
按指定的宽度、高度重设图片大小后保存
|
static void |
resizeWriteImage(File srcFile,
int newWidth,
int newHeight,
File targetFile)
按指定的宽度、高度重设图片大小后保存
|
static void |
resizeWriteImageByWidth(byte[] bytes,
int newWith,
File targetFile)
根据宽度按比例缩放
|
static void |
resizeWriteImageByWidth(File srcFile,
int newWith,
File targetFile)
根据宽度按比例缩放
|
static BufferedImage |
watermarkText(String logoText,
Color fontColor,
String fontName,
int fontSize,
float alpha,
int pointX,
int pointY,
Integer degree,
BufferedImage bufferedImage)
给图片添加文字水印、可设置水印的旋转角度
|
public static void resizeAddLogoSave(InputStream srcImage, InputStream waterImage, int maxImgWidth, float alpha, int pointX, int pointY, Integer degree, String targetPath)
srcImage - the src imagewaterImage - the water imagemaxImgWidth - the max img widthalpha - the alphapointX - the point xpointY - the point ydegree - 水印图片旋转角度targetPath - 目标图片路径public static BufferedImage watermarkText(String logoText, Color fontColor, String fontName, int fontSize, float alpha, int pointX, int pointY, Integer degree, BufferedImage bufferedImage)
logoText - the logo text 水印文字fontColor - the font color 水印文字颜色fontName - the font name 水印字体fontSize - the font size 水印字体大小alpha - the alpha 水印字体透明度pointX - the point x 水印字体X坐标pointY - the point y 水印字体Y坐标degree - the degree 水印字段旋转角度bufferedImage - the buffered image 水印图片对象public static void resizeAddLogoWrite(InputStream inputStream, String logoText, int maxImgWidth, Color fontColor, String fontName, int fontSize, float alpha, int pointX, int pointY, Integer degree, String targetPath)
inputStream - the input stream 图片文件流logoText - the logo text 水印文字maxImgWidth - the max img width 图片重设大小最大宽度fontColor - the font color 水印文件颜色fontName - the font name 水印文字字体fontSize - the font size 水印文字大小alpha - the alpha 水印文字透明度pointX - the point x 水印文字x坐标pointY - the point y 水印文字y坐标degree - the degree 水印文字旋转角度targetPath - the target path 加工后图片保存路径public static int[] getImageWH(File imageFile)
imageFile - 图片文件public static int[] getImageWH(byte[] bytes)
bytes - 图片byte数组public static void resizeWriteByMaxSize(byte[] bytes,
int maxSize,
File targetFile)
bytes - maxSize - targetFile - public static void resizeWriteByMaxSize(File srcFile, int maxSize, File targetFile)
srcFile - maxSize - targetFile - public static void resizeWriteImageByWidth(byte[] bytes,
int newWith,
File targetFile)
bytes - newWith - targetFile - public static void resizeWriteImageByWidth(File srcFile, int newWith, File targetFile)
srcFile - newWith - targetFile - public static void resizeWriteImage(byte[] bytes,
int newWidth,
int newHeight,
File targetFile)
bytes - newWidth - newHeight - targetFile - public static void resizeWriteImage(File srcFile, int newWidth, int newHeight, File targetFile)
srcFile - newWidth - newHeight - targetFile - public static byte[] resizeByMaxSize(byte[] bytes,
int maxSize)
bytes - the bytesmaxSize - the max sizepublic static byte[] resizeByMaxSize(File srcFile, int maxSize)
srcFile - the src filemaxSize - the max sizepublic static byte[] resizeImageByWidth(byte[] bytes,
int newWith)
bytes - the bytesnewWith - the new withpublic static byte[] resizeImageByWidth(File srcFile, int newWith)
srcFile - the src filenewWith - the new withpublic static byte[] resizeImage(byte[] bytes,
int newWidth,
int newHeight)
bytes - the bytesnewWidth - the new widthnewHeight - the new heightpublic static byte[] resizeImage(File srcFile, int newWidth, int newHeight)
srcFile - the src filenewWidth - the new widthnewHeight - the new heightpublic static byte[] resizeCutImage(byte[] bytes,
int cutWidth,
int cutHeight)
cutWidth - cutHeight - public static byte[] resizeCutImage(File srcFile, int cutWidth, int cutHeight)
srcFile - cutWidth - cutHeight - public static void resizeCutWriteImage(File srcFile, int newWidth, int newHeight, File targetFile)
srcFile - newWidth - newHeight - targetFile - public static void resizeCutWriteImage(byte[] bytes,
int newWidth,
int newHeight,
File targetFile)
bytes - newWidth - newHeight - targetFile - public static byte[] cutImage(File imageFile, int x, int y, int cutWidth, int cutHeight)
imageFile - 图片文件x - 起始x坐标y - 起始y坐标cutWidth - 裁切的宽度cutHeight - 裁切的高度public static byte[] cutImage(byte[] imageBytes,
int x,
int y,
int cutWidth,
int cutHeight)
imageBytes - 图片文件x - 起始x坐标y - 起始y坐标cutWidth - 裁切的宽度cutHeight - 裁切的高度public static String getImageFormat(byte[] image)
image - Copyright © 2016. All rights reserved.