|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.io.ImageUtil
public class ImageUtil
Utility class to manipulate image.
Field Summary | |
---|---|
static String |
REVISION
|
Constructor Summary | |
---|---|
ImageUtil()
|
Method Summary | |
---|---|
static File |
createGIFThumbnail(File imageFile,
int maxWidth,
int maxHeight)
Creates a thumbnail of the given file image in a temporary location in the GIF format, return the corresponding File. |
static File |
createJPEGThumbnail(File imageFile,
int maxWidth,
int maxHeight)
Creates a thumbnail of the given file image in a temporary location in the JPEG format, return the corresponding File. |
static File |
createThumbnail(File imageFile,
ImageFormat format,
int maxWidth,
int maxHeight)
|
static File |
createThumbnail(File imageFile,
ImageFormat format,
int maxWidth,
int maxHeight,
String background)
Creates a thumbnail of the given file image in a temporary location in the given format, return the corresponding File. |
static File |
crop(File imageFile,
ImageFormat format,
int x1,
int y1,
int x2,
int y2,
String background)
|
static BufferedImage |
cropImage(BufferedImage image,
int x1,
int y1,
int x2,
int y2,
String background)
|
static BufferedImage |
getScaledInstance(BufferedImage img,
int targetWidth,
int targetHeight,
Object hint,
boolean higherQuality)
Convenience method that returns a scaled instance of the provided BufferedImage . |
static String[] |
getSupportedReadFormat()
|
static String[] |
getSupportedWriteFormat()
|
static boolean |
isImage(File file)
Detects if the given file is an image file, using its extension. |
static BufferedImage |
readImage(File file)
Read the given image file and return the BufferedImage |
static BufferedImage |
resizeImage(BufferedImage image,
int maxWidth,
int maxHeight,
boolean doNotEnlarge,
String background)
Resizes the given BufferedImage to a new BufferedImage file with the given sizes. |
static File |
rotate(File imageFile,
ImageFormat format,
int angle,
String background)
|
static BufferedImage |
rotateImage(BufferedImage image,
int angle,
String background)
|
static void |
setQualityRenderingHints(Graphics2D g2d)
|
static File |
writeGIF(BufferedImage image,
File outFile)
Write the given BufferedImage to the given outfile in GIF format. |
static File |
writeJPEG(BufferedImage image,
File outFile)
Write the given BufferedImage to the given outfile in JPEG format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
Constructor Detail |
---|
public ImageUtil()
Method Detail |
---|
public static boolean isImage(File file)
file
- the file to check
public static File createGIFThumbnail(File imageFile, int maxWidth, int maxHeight)
imageFile
- the image file of which to make a thumbnail.maxWidth
- the maximum width of the output imagemaxHeight
- the maximum height of the output image
createThumbnail(File, ImageFormat, int, int)
public static File createJPEGThumbnail(File imageFile, int maxWidth, int maxHeight)
imageFile
- the image file of which to make a thumbnail.maxWidth
- the maximum width of the output imagemaxHeight
- the maximum height of the output image
createThumbnail(File, ImageFormat, int, int)
public static File createThumbnail(File imageFile, ImageFormat format, int maxWidth, int maxHeight)
createThumbnail(File, ImageFormat, int, int, String)
public static File createThumbnail(File imageFile, ImageFormat format, int maxWidth, int maxHeight, String background)
imageFile
- the image file of which to make a thumbnail.format
- the image format to use, ImageFormat.GIF
, ImageFormat.JPEG
,
if null the ImageFormat.JPEG
format is usedmaxWidth
- the maximum width of the output imagemaxHeight
- the maximum height of the output imagebackground
- the background color (eg "FFFFFF") if sets the image dimension will be set maxWidth and maxHeight
public static BufferedImage readImage(File file)
file
- the image file to read
IllegalArgumentException
- if file is null.public static void setQualityRenderingHints(Graphics2D g2d)
public static BufferedImage getScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality)
BufferedImage
.
http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
img
- the original image to be scaledtargetWidth
- the desired width of the scaled instance,
in pixelstargetHeight
- the desired height of the scaled instance,
in pixelshint
- one of the rendering hints that corresponds to
RenderingHints.KEY_INTERPOLATION
(e.g.
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
,
RenderingHints.VALUE_INTERPOLATION_BILINEAR
,
RenderingHints.VALUE_INTERPOLATION_BICUBIC
)higherQuality
- if true, this method will use a multi-step
scaling technique that provides higher quality than the usual
one-step technique (only useful in downscaling cases, where
targetWidth
or targetHeight
is
smaller than the original dimensions, and generally only when
the BILINEAR
hint is specified)
BufferedImage
public static File rotate(File imageFile, ImageFormat format, int angle, String background)
public static BufferedImage rotateImage(BufferedImage image, int angle, String background)
public static File crop(File imageFile, ImageFormat format, int x1, int y1, int x2, int y2, String background)
public static BufferedImage cropImage(BufferedImage image, int x1, int y1, int x2, int y2, String background)
public static BufferedImage resizeImage(BufferedImage image, int maxWidth, int maxHeight, boolean doNotEnlarge, String background)
image
- the image to resize.maxWidth
- the maximum width of the output imagemaxHeight
- the maximum height of the output imagedoNotEnlarge
- do not increase image size if image is smaller than given maximum dimension.background
- the background color (eg "FFFFFF") if sets the image dimension will be set maxWidth and maxHeight
IllegalArgumentException
- if image is null.public static File writeJPEG(BufferedImage image, File outFile)
image
- the BufferedImage to write to a file.outFile
- the file in which to write the image
IllegalArgumentException
- if image or outFile is null.public static File writeGIF(BufferedImage image, File outFile)
image
- the BufferedImage to write to a file.outFile
- the file in which to write the image
IllegalArgumentException
- if image or outFile is null.public static String[] getSupportedReadFormat()
ImageIO.getReaderFormatNames()
public static String[] getSupportedWriteFormat()
ImageIO.getWriterFormatNames()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |