fc.util
Class ImageUtil

java.lang.Object
  extended by fc.util.ImageUtil

public final class ImageUtil
extends Object


Constructor Summary
ImageUtil()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUtil

public ImageUtil()
Method Detail

resize

public static void resize(File sourceFile,
                          File targetFile,
                          String format,
                          int newWidth,
                          int newHeight)
                   throws IOException
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).

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).

Throws:
IOException

resize

public static void resize(File sourceFile,
                          File targetFile,
                          int newWidth,
                          int newHeight)
                   throws IOException
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).

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).

Throws:
IOException

resize

public static BufferedImage resize(File sourceFile,
                                   int newWidth,
                                   int newHeight)
                            throws IOException
Resizes the specified image file to the new width and height and returns the new image.

Throws:
IOException

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException