类 ImageUtil
java.lang.Object
com.sh.wf.module.util.ImageUtil
Description:
Title:首亨软件 - TSS/CRM等
- 从以下版本开始:
- 2017年1月6日
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleancutImage(File file, String dest, int destWidth, int destHeight, int x, int y, int width, int height) 保存图片static booleancutImage(String source, String dest, int srcWidth, int srcHeight, int x, int y, int width, int height) static StringgetBase64ByImage(File file) 将图片文件转换为base64字符串static StringgetBase64ByImage(File file, int maxWidthHeight) 图片缩放并转base64static int[]获取图片的宽度或调度static InputStreamgetInputStreamByBase64(String base64Data) 将图片的base64的字符串数据转化为InputStream流static BufferedImagegetScaleByHttpImg(String httpUrl, int destWidth, int destHeight) 通过网络图片生成static BufferedImagegetScaleImg(BufferedImage bi, int destWidth, int destHeight) 图缩放static BufferedImagegetScaleImg(File file, int destWidth, int destHeight) 图缩放static voidmarkWaterContent(String srcImgPath, String outImgPath, JSONObject config) static voidmarkWaterContent(String srcImgPath, String outImgPath, Color markContentColor, int degree, float alpha, String waterMarkContent) 给图片添加水印、可设置水印图片旋转角度static voidmarkWaterContent(String srcImgPath, String outImgPath, String waterMarkContent) 给图片添加水印static booleanscaleImage(File file, String dest, int destWidth, int destHeight) 缩放图片
-
构造器详细资料
-
ImageUtil
public ImageUtil()
-
-
方法详细资料
-
cutImage
-
cutImage
public static boolean cutImage(File file, String dest, int destWidth, int destHeight, int x, int y, int width, int height) 保存图片- 参数:
file- 原图dest- 目标图路径destWidth- 原始图缩放宽度destHeight- 原始图缩放高度x- 选择框的左边x坐标y- 选择框的左边y坐标width- 选择框宽度height- 选择框高度- 返回:
- boolean
-
scaleImage
缩放图片- 参数:
file- 图片文件dest- 缩放后存放路径destWidth- 缩放宽度destHeight- 缩放高度- 返回:
- boolean
-
getScaleImg
图缩放- 参数:
file- 图片文件destWidth- 缩放宽度destHeight- 缩放高度- 返回:
- BufferedImage
-
getScaleByHttpImg
通过网络图片生成- 参数:
httpUrl- StringdestWidth- intdestHeight- int- 返回:
- BufferedImage
-
getScaleImg
图缩放- 参数:
bi- 图片文件destWidth- 缩放宽度destHeight- 缩放高度- 返回:
- BufferedImage
-
markWaterContent
给图片添加水印- 参数:
srcImgPath- 源图片路径outImgPath- 目标图片路径waterMarkContent- 水印文本 支持json带配置参数 {"color":"","degree":-20,"alpha":0.5,"text":"水印内容"}
-
markWaterContent
public static void markWaterContent(String srcImgPath, String outImgPath, Color markContentColor, int degree, float alpha, String waterMarkContent) 给图片添加水印、可设置水印图片旋转角度- 参数:
srcImgPath- 源图片路径outImgPath- 目标图片路径markContentColor- 水印文本degree- 旋转角度alpha- 透明度(0.0 -- 1.0, 0.0为完全透明,1.0为完全不透明)waterMarkContent- String
-
markWaterContent
-
getInputStreamByBase64
将图片的base64的字符串数据转化为InputStream流- 参数:
base64Data- String- 返回:
- InputStream
-
getBase64ByImage
将图片文件转换为base64字符串- 参数:
file-- 返回:
-
getBase64ByImage
图片缩放并转base64- 参数:
file-maxWidthHeight-- 返回:
-
getImageWidthHeight
获取图片的宽度或调度- 参数:
src- 网络图片或本地图片,要求必须完整路径- 返回:
- int[]
-