Constructor and Description |
---|
ImageUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args) |
static void |
resize(File sourceFile,
File targetFile,
int newWidth,
int newHeight)
Resizes the specified image file to the new width and height and writes it to
the targetFile (creating the targetFile if it does not already exist).
|
static void |
resize(File sourceFile,
File targetFile,
String format,
int newWidth,
int newHeight)
Resizes the specified image file to the new width and height and writes it to
the targetFile (creating the targetFile if it does not already exist).
|
static BufferedImage |
resize(File sourceFile,
int newWidth,
int newHeight)
Resizes the specified image file to the new width and height and returns the
new image.
|
public ImageUtil()
public static void resize(File sourceFile, File targetFile, String format, int newWidth, int newHeight) throws IOException
The format string is the output format of the file, like "jpg", "gif" etc. This
can be different than the format of the source file. The understood formats
are those understood javax.io.ImageWriter
(the usual suspects like gif,
jpg, png, etc, all seem to work).
IOException
public static void resize(File sourceFile, File targetFile, int newWidth, int newHeight) throws IOException
The output format is the same as the input format and is intuited from the file
name extension of the specified source file (therefore, source files specified
to this method, should be like foo.gif
, foo.jpg
, etc).
IOException
public static BufferedImage resize(File sourceFile, int newWidth, int newHeight) throws IOException
IOException
public static void main(String[] args) throws IOException
IOException