Class ImageUtil

java.lang.Object
fc.util.ImageUtil

public final class ImageUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String[] args)
     
    resize(File sourceFile, int newWidth, int newHeight)
    Resizes the specified image file to the new width and height and returns the new image.
    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).

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • 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

      invalid reference
      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