public class ImageUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
IMAGE_FORMAT_JPEG
jpeg image format
|
static String |
IMAGE_FORMAT_JPG
jpg image format
|
static String |
IMAGE_FORMAT_PNG
png image format
|
Constructor and Description |
---|
ImageUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
closeQuietly(Closeable closeable)
Close quietly
|
static byte[] |
compressAndWriteImageToBytes(BufferedImage image,
String formatName,
float quality)
Compress and write the image to bytes in the provided format and quality
|
static BufferedImage |
createBufferedImage(int width,
int height,
String imageFormat)
Create a buffered image for the dimensions and image format
|
static BufferedImage |
getImage(byte[] imageBytes)
Get a buffered image of the image bytes
|
static boolean |
isFullyTransparent(BufferedImage image)
Check if the image is fully transparent, meaning it contains only
transparent pixels as an empty image
|
static boolean |
isTransparent(BufferedImage image,
int x,
int y)
Check if the pixel in the image at the x and y is transparent
|
static byte[] |
writeImageToBytes(BufferedImage image,
String formatName)
Write the image to bytes in the provided format
|
static byte[] |
writeImageToBytes(BufferedImage image,
String formatName,
Float quality)
Write the image to bytes in the provided format and optional quality
|
public static final String IMAGE_FORMAT_PNG
public static final String IMAGE_FORMAT_JPG
public static final String IMAGE_FORMAT_JPEG
public static BufferedImage createBufferedImage(int width, int height, String imageFormat)
width
- height
- imageFormat
- public static boolean isFullyTransparent(BufferedImage image)
image
- public static boolean isTransparent(BufferedImage image, int x, int y)
image
- x
- y
- public static BufferedImage getImage(byte[] imageBytes) throws IOException
imageBytes
- IOException
public static byte[] writeImageToBytes(BufferedImage image, String formatName, Float quality) throws IOException
image
- buffered imageformatName
- image format namequality
- null or quality between 0.0 and 1.0IOException
public static byte[] writeImageToBytes(BufferedImage image, String formatName) throws IOException
image
- buffered imageformatName
- image format nameIOException
public static byte[] compressAndWriteImageToBytes(BufferedImage image, String formatName, float quality)
image
- buffered imageformatName
- image format namequality
- quality between 0.0 and 1.0IOException
public static void closeQuietly(Closeable closeable)
closeable
- Copyright © 2015 National Geospatial-Intelligence Agency. All rights reserved.