public class MyImageUtils extends Object
| 构造器和说明 |
|---|
MyImageUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
bytesToImg(byte[] bytes,
String savePath)
将二进制转换为图片
|
static String |
bytesToImgBase64(byte[] bytes)
图片字节数组转base64
|
static boolean |
changeSize(File file,
int newWidth,
int newHeight)
改变图片的尺寸
|
static boolean |
changeSize(String path,
int newWidth,
int newHeight)
改变图片的尺寸
|
static File |
changeSizeToNewFile(File file,
int newWidth,
int newHeight)
改变图片的尺寸
|
static File |
changeSizeToNewFile(String path,
int newWidth,
int newHeight)
改变图片的尺寸
|
static Boolean |
imageCheck(File file)
检查是否为图片
|
static byte[] |
imgBase64ToBytes(String base64)
将图片BASE64字符串转为二进制数组
|
static File |
imgFormatConvert(File file,
String formatName)
图片格式转换
|
static File |
imgFormatConvert(String imgPath,
String formatName)
图片格式转换
|
static byte[] |
imgToBytes(String imgPath)
图片/文件转二进制数组,这个方法有很多,只写一个
|
static byte[] |
toTransparency(InputStream is)
去除图片背景,转透明图
|
public static byte[] imgBase64ToBytes(String base64)
base64 - new Image();img.src或canvas.toDataURL("image/png")IOExceptionpublic static String bytesToImgBase64(byte[] bytes)
public static byte[] imgToBytes(String imgPath)
imgPath - 图片路径public static void bytesToImg(byte[] bytes,
String savePath)
savePath - 将图片输出到哪里public static byte[] toTransparency(InputStream is)
is - public static boolean changeSize(File file, int newWidth, int newHeight)
newWidth, - newHeight, pathpublic static boolean changeSize(String path, int newWidth, int newHeight)
path - 文件路径newWidth - 需要设置的宽度newHeight - 需要设置的高度public static File changeSizeToNewFile(String path, int newWidth, int newHeight)
path - 文件路径newWidth - 需要设置的宽度newHeight - 需要设置的高度Copyright © 2019. All rights reserved.