public class ImageUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
REQUIRED_IMAGE_TYPE |
| Constructor and Description |
|---|
ImageUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
base64FromImage(BufferedImage image) |
static BufferedImage |
copyImageWithType(BufferedImage src,
int updatedType)
Creates a copy of an image with an updated image type.
|
static BufferedImage |
cropImage(BufferedImage image,
Region regionToCrop)
Removes a given region from the image.
|
static byte[] |
encodeAsPng(BufferedImage image)
Encodes a given image as PNG.
|
static BufferedImage |
getImagePart(BufferedImage image,
Region region)
Get a copy of the part of the image given by region.
|
static BufferedImage |
imageFromBase64(String image64)
Creates a
BufferedImage instance from a base64 encoding of an
image's bytes. |
static BufferedImage |
imageFromBytes(byte[] imageBytes)
Creates a BufferedImage instance from raw image bytes.
|
static BufferedImage |
imageFromFile(String path)
Creates a
BufferedImage from an image file specified by path. |
static BufferedImage |
imageFromResource(String resource)
Creates a
BufferedImage from an image file specified by resource. |
static BufferedImage |
normalizeImageType(BufferedImage image) |
static BufferedImage |
resizeImage(BufferedImage image,
int targetWidth,
int targetHeight)
Scales an image by the given ratio
|
static BufferedImage |
rotateImage(BufferedImage image,
double deg)
Rotates an image by the given degrees.
|
static void |
saveImage(BufferedImage image,
String filename)
Save image to local file system
|
static BufferedImage |
scaleImage(BufferedImage image,
double scaleRatio)
Scales an image by the given ratio
|
static BufferedImage |
scaleImage(BufferedImage image,
ScaleProvider scaleProvider)
Scales an image by the given ratio
|
public static final int REQUIRED_IMAGE_TYPE
public static BufferedImage normalizeImageType(BufferedImage image)
public static byte[] encodeAsPng(BufferedImage image)
image - The image to encode.public static BufferedImage imageFromFile(String path) throws EyesException
BufferedImage from an image file specified by path.path - The path to the image file.BufferedImage instance.EyesException - If there was a problem
creating the BufferedImage instance.public static BufferedImage imageFromResource(String resource) throws EyesException
BufferedImage from an image file specified by resource.resource - The resource path.BufferedImage instance.EyesException - If there was a problem
creating the BufferedImage instance.public static BufferedImage imageFromBase64(String image64) throws EyesException
BufferedImage instance from a base64 encoding of an
image's bytes.image64 - The base64 encoding of an image's bytes.BufferedImage instance.EyesException - If there was a problem
creating the BufferedImage instance.public static String base64FromImage(BufferedImage image)
image - The image from which to get its base64 representation.public static BufferedImage imageFromBytes(byte[] imageBytes) throws EyesException
imageBytes - The raw bytes of the image.EyesException - If there was a problem
creating the BufferedImage instance.public static BufferedImage getImagePart(BufferedImage image, Region region)
image - The image from which to get the part.region - The region which should be copied from the image.public static BufferedImage rotateImage(BufferedImage image, double deg)
image - The image to rotate.deg - The degrees by which to rotate the image.public static BufferedImage copyImageWithType(BufferedImage src, int updatedType)
src - The image to copy.updatedType - The type of the copied image.
See BufferedImage.getType().src of the requested type.public static BufferedImage scaleImage(BufferedImage image, ScaleProvider scaleProvider)
image - The image to scale.scaleProvider - The encapsulation of the required scaling.public static BufferedImage scaleImage(BufferedImage image, double scaleRatio)
image - The image to scale.scaleRatio - Factor to multiply the image dimensions bypublic static BufferedImage resizeImage(BufferedImage image, int targetWidth, int targetHeight)
image - The image to scale.targetWidth - The width to resize the image totargetHeight - The height to resize the image topublic static BufferedImage cropImage(BufferedImage image, Region regionToCrop)
image - The image to crop.regionToCrop - The region to crop from the image.public static void saveImage(BufferedImage image, String filename)
image - The image to save.filename - The path to save imageCopyright © 2017. All rights reserved.