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 x,
int y,
int height,
int width)
Crop the image by a specified rectangular region.
|
protected static BufferedImage |
_resizeImage(BufferedImage src,
int height,
int width,
int maxHeight,
int maxWidth)
Resize the buffered image
|
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 void |
generateThumbnail(InputStream is,
OutputStream os,
String format,
int height,
int width,
int maxHeight,
int maxWidth)
Generates a thumbnail from a source InputStream.
|
static BufferedImage |
read(InputStream is)
Returns a BufferedImage as from the supplied input stream
|
private ImageHelper()
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) 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 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 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 _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