public final class ImageHelper extends Object
| Modifier | Constructor and Description |
|---|---|
private |
ImageHelper() |
| Modifier and Type | Method and Description |
|---|---|
protected static BufferedImage |
_cropImage(BufferedImage src,
int height,
int width)
Crop the image to the size specified to the center of the image.
|
protected static BufferedImage |
_cropImage(BufferedImage src,
int x,
int y,
int height,
int width)
Crop the image by a specified rectangular region.
|
private static boolean |
_isJpeg(String format) |
private static boolean |
_needsChanges(int height,
int width,
int maxHeight,
int maxWidth,
int cropHeight,
int cropWidth) |
protected static BufferedImage |
_resizeImage(BufferedImage src,
int height,
int width,
int maxHeight,
int maxWidth)
Resize the buffered image
|
static BufferedImage |
generateCroppedImage(BufferedImage src,
int height,
int width)
Crop the image in the center, at the specified dimensions.
|
static BufferedImage |
generateCroppedImage(BufferedImage src,
int x,
int y,
int height,
int width)
Crop the image by a specified rectangular region.
|
static void |
generateCroppedImage(InputStream is,
OutputStream os,
String format,
int x,
int y,
int height,
int width)
Crop an image from a source InputStream.
|
static BufferedImage |
generateThumbnail(BufferedImage src,
int height,
int width,
int maxHeight,
int maxWidth)
Generates a BufferedImage with specified size instructions, scaling if necessary.
|
static BufferedImage |
generateThumbnail(BufferedImage src,
int height,
int width,
int maxHeight,
int maxWidth,
int cropHeight,
int cropWidth)
Generates a BufferedImage with specified size instructions, scaling if necessary.
If the image should be both cropped and resized, the resizing will be done after the cropping. |
static void |
generateThumbnail(InputStream is,
OutputStream os,
String format,
int height,
int width,
int maxHeight,
int maxWidth)
Generates a thumbnail from a source InputStream.
|
static void |
generateThumbnail(InputStream is,
OutputStream os,
String format,
int height,
int width,
int maxHeight,
int maxWidth,
int cropHeight,
int cropWidth)
Generates a thumbnail from a source InputStream.
|
static BufferedImage |
read(InputStream is)
Returns a BufferedImage as from the supplied input stream
|
private ImageHelper()
private static boolean _needsChanges(int height, int width, int maxHeight, int maxWidth, int cropHeight, int cropWidth)
public static BufferedImage read(InputStream is) throws IOException
is - The input streamIOException - if an error occurs during reading.public static void generateThumbnail(InputStream is, OutputStream os, String format, int height, int width, int maxHeight, int maxWidth, int cropHeight, int cropWidth) throws IOException
is - the source.os - the destination.format - the image format. Must be one of "gif", "png" or "jpg".height - the specified height. Ignored if negative.width - the specified width. Ignored if negative.maxHeight - the maximum image height. Ignored if height or width is specified.maxWidth - the maximum image width. Ignored if height or width is specified.cropHeight - the height of the cropped image. Ignore if negative.cropWidth - the width of the cropped image. Ignore if negative.IOException - if an error occurs when manipulating streams.public static BufferedImage generateThumbnail(BufferedImage src, int height, int width, int maxHeight, int maxWidth, int cropHeight, int cropWidth) throws IOException
src - the source image.height - the specified height. Ignored if negative.width - the specified width. Ignored if negative.maxHeight - the maximum image height. Ignored if height or width is specified.maxWidth - the maximum image width. Ignored if height or width is specified.cropHeight - the height of the cropped image. Ignore if negative.cropWidth - the width of the cropped image. Ignore if negative.IOException - If the source image is not readablepublic static void generateThumbnail(InputStream is, OutputStream os, String format, int height, int width, int maxHeight, int maxWidth) throws IOException
is - the source.os - the destination.format - the image format. Must be one of "gif", "png" or "jpg".height - the specified height. Ignored if negative.width - the specified width. Ignored if negative.maxHeight - the maximum image height. Ignored if height or width is specified.maxWidth - the maximum image width. Ignored if height or width is specified.IOException - if an error occurs when manipulating streams.public static BufferedImage generateThumbnail(BufferedImage src, int height, int width, int maxHeight, int maxWidth) throws IOException
src - the source image.height - the specified height. Ignored if negative.width - the specified width. Ignored if negative.maxHeight - the maximum image height. Ignored if height or width is specified.maxWidth - the maximum image width. Ignored if height or width is specified.IOException - If the source image is not readablepublic static void generateCroppedImage(InputStream is, OutputStream os, String format, int x, int y, int height, int width) throws IOException
is - the source.os - the destination.format - the image format. Must be one of "gif", "png" or "jpg".x - The X coordinate of the upper-left corner of the specified rectangular regiony - the Y coordinate of the upper-left corner of the specified rectangular regionheight - the width of the specified rectangular regionwidth - the height of the specified rectangular regionIOException - If an error occurspublic static BufferedImage generateCroppedImage(BufferedImage src, int height, int width) throws IOException
BufferedImage shares the same data array as the original image.src - the source image.height - the width of the specified rectangular regionwidth - the height of the specified rectangular regionIOException - If the source image is not readablepublic static BufferedImage generateCroppedImage(BufferedImage src, int x, int y, int height, int width) throws IOException
BufferedImage shares the same data array as the original image.src - the source image.x - The X coordinate of the upper-left corner of the specified rectangular regiony - the Y coordinate of the upper-left corner of the specified rectangular regionheight - the width of the specified rectangular regionwidth - the height of the specified rectangular regionIOException - If the source image is not readableprotected static BufferedImage _cropImage(BufferedImage src, int height, int width) throws IOException
src - the source image.height - the width of the specified rectangular regionwidth - the height of the specified rectangular regionIOException - If the source image is not readableprotected static BufferedImage _cropImage(BufferedImage src, int x, int y, int height, int width) throws IOException
BufferedImage shares the same data array as the original image.src - the source image.x - The X coordinate of the upper-left corner of the specified rectangular region.y - the Y coordinate of the upper-left corner of the specified rectangular region.height - the width of the specified rectangular regionwidth - the height of the specified rectangular regionIOException - If the source image is not readableprotected static BufferedImage _resizeImage(BufferedImage src, int height, int width, int maxHeight, int maxWidth) throws IOException
src - the source imageheight - the specified height. Ignored if negative.width - the specified width. Ignored if negative.maxHeight - the maximum image height. Ignored if height or width is specified.maxWidth - the maximum image width. Ignored if height or width is specified.IOException - If the source image is not readable