public class ImageHelper extends Object
Modifier and Type | Field and Description |
---|---|
static int |
USER_IMAGE_MAX_SIZE
The maximum of the image size is 5000 bytes
|
Modifier and Type | Method and Description |
---|---|
static BufferedImage |
byteToImage(byte[] data)
Converts the byte array to an image.
|
static byte[] |
copyExifOrientation(byte[] sourceImage,
byte[] result)
This method will copy the Exif "orientation" information to the resulting image, if the
original image contains this data too.
|
static boolean |
createImageFile(byte[] data,
String filename)
Creates an image file and save it to the cache directory
|
static String |
getMimeType(byte[] image)
Method to get the best mime type for the given image.
|
static byte[] |
imageFileToByteArray(File file,
String format)
Return the given image file as byte array
|
static byte[] |
imageToByte(BufferedImage image,
String format)
Converts an image to a byte array in the given image format.
|
static byte[] |
imageToByte(BufferedImage image,
String format,
Float compressionQuality)
Converts an image to a byte array in the given image format
|
static BufferedImage |
loadImage(File file)
Loads an image from a file.
|
public static final int USER_IMAGE_MAX_SIZE
public static BufferedImage byteToImage(byte[] data)
data
- Image as binary data.public static byte[] copyExifOrientation(byte[] sourceImage, byte[] result)
sourceImage
- The source image.result
- The original result.public static boolean createImageFile(byte[] data, String filename)
data
- Image binary datafilename
- Destination path of the given filetrue
, else
false
public static String getMimeType(byte[] image)
image
- The image to check.public static byte[] imageFileToByteArray(File file, String format)
file
- Image fileformat
- Image formatpublic static byte[] imageToByte(BufferedImage image, String format)
image
- BufferedImage objectformat
- Format for the transformationpublic static byte[] imageToByte(BufferedImage image, String format, Float compressionQuality)
image
- BufferedImage objectformat
- Format for the transformationcompressionQuality
- optional parameter to set a compression quality. The value is expected to be
between 0 and 1 where 0 is interpreted as high compression and 1 as high quality.
When passing null the image won't be compressed.public static BufferedImage loadImage(File file)
file
- FileCopyright © 2019 Communote team. All rights reserved.