com.nurelm.util
Class ImageUtil

java.lang.Object
  extended bycom.nurelm.util.ImageUtil

public class ImageUtil
extends java.lang.Object

DOCUMENT ME!


Field Summary
static java.lang.String IMAGE_REDUCTION_ERROR
          DOCUMENT ME!
static float NO_MAX_H_SET
          DOCUMENT ME!
static float NO_MAX_W_SET
          DOCUMENT ME!
 
Constructor Summary
ImageUtil()
           
 
Method Summary
static java.lang.String convertFileNameToResizedJpeg(java.lang.String pathFileName)
          Changes the file extension to "jpg" and returns the new string.
static boolean isFileJpegOrGif(java.lang.String filename)
          DOCUMENT ME!
static java.lang.String reduceAndDeleteOldIfNeeded(java.lang.String originalImagePathFileName, java.lang.String newMaxHeight, java.lang.String newMaxWidth)
          If the passed in dimensions are smaller than the image, the image is reduced in size.
static java.lang.String reduceIfNeeded(java.lang.String originalImagePathFileName, float newMaxHeight, float newMaxWidth)
           
static void resize(java.lang.String originalImageFileName, java.lang.String newImageFilename, float newMaxHeight, float newMaxWidth)
          Resizes the originalImageFileName to the same proportions, but maximum dimensions of newMaxHeight X newMaxWidth (in pixels).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_MAX_H_SET

public static final float NO_MAX_H_SET
DOCUMENT ME!

See Also:
Constant Field Values

NO_MAX_W_SET

public static final float NO_MAX_W_SET
DOCUMENT ME!

See Also:
Constant Field Values

IMAGE_REDUCTION_ERROR

public static final java.lang.String IMAGE_REDUCTION_ERROR
DOCUMENT ME!

See Also:
Constant Field Values
Constructor Detail

ImageUtil

public ImageUtil()
Method Detail

reduceIfNeeded

public static java.lang.String reduceIfNeeded(java.lang.String originalImagePathFileName,
                                              float newMaxHeight,
                                              float newMaxWidth)
                                       throws NuPlatformException,
                                              NuFileException
Throws:
NuPlatformException
NuFileException

reduceAndDeleteOldIfNeeded

public static java.lang.String reduceAndDeleteOldIfNeeded(java.lang.String originalImagePathFileName,
                                                          java.lang.String newMaxHeight,
                                                          java.lang.String newMaxWidth)
                                                   throws NuPlatformException,
                                                          java.lang.NumberFormatException,
                                                          NuFileException
If the passed in dimensions are smaller than the image, the image is reduced in size. The new fileName (w/o path prepended to it) for the image is returned. The original file is deleted.

Parameters:
originalImagePathFileName - DOCUMENT ME!
newMaxHeight - DOCUMENT ME!
newMaxWidth - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
NuPlatformException - DOCUMENT ME!
java.lang.NumberFormatException - DOCUMENT ME!
NuFileException - DOCUMENT ME!

resize

public static void resize(java.lang.String originalImageFileName,
                          java.lang.String newImageFilename,
                          float newMaxHeight,
                          float newMaxWidth)
                   throws NuPlatformException
Resizes the originalImageFileName to the same proportions, but maximum dimensions of newMaxHeight X newMaxWidth (in pixels). New image is saved to a file specified by newImageFilename. Most image types are accepted (all those that JAI can handle.) All images, regardless of type, are saved as JPEG.

Parameters:
originalImageFileName - DOCUMENT ME!
newImageFilename - DOCUMENT ME!
newMaxHeight - DOCUMENT ME!
newMaxWidth - DOCUMENT ME!
Throws:
NuPlatformException - DOCUMENT ME!

isFileJpegOrGif

public static boolean isFileJpegOrGif(java.lang.String filename)
DOCUMENT ME!

Parameters:
filename - DOCUMENT ME!
Returns:
DOCUMENT ME!

convertFileNameToResizedJpeg

public static java.lang.String convertFileNameToResizedJpeg(java.lang.String pathFileName)
                                                     throws NuPlatformException,
                                                            NuFileException
Changes the file extension to "jpg" and returns the new string. If the file does not have an extension, then null is returned. Verifies that the new file name is unique. Example: joe.jpg -> joe_resized.jgg joe.jpg (if joe_resized.jpg exists) -> joe_resized_copy1.jpg

Parameters:
pathFileName - pathFileName Must be absolute!
Returns:
DOCUMENT ME!
Throws:
NuPlatformException - DOCUMENT ME!
NuFileException - DOCUMENT ME!