de.uplanet.lucy.server.scripting.groovy
Class ImageHelper

java.lang.Object
  extended by de.uplanet.lucy.server.scripting.groovy.ImageHelper

@Scriptable
public final class ImageHelper
extends java.lang.Object

Version:
$Revision: 86610 $

Method Summary
static IMAGE_FORMAT getImageFormat(java.io.File p_file)
          Get the image format of the given file.
static IMAGE_FORMAT getImageFormat(java.lang.String p_strPath)
          Get the image format of the given file.
static Size getImageSize(java.io.File p_file)
          Determine the size of the given image.
static Size getImageSize(java.lang.String p_strImagePath)
          Determine the size of the given image.
static boolean isSupportedImageFormat(java.io.File p_file)
          Check if the given file has a supported image format.
static boolean isSupportedImageFormat(java.lang.String p_strPath)
          Check if the given file has a supported image format.
static void scaleImage(java.util.Map<java.lang.String,java.lang.Object> p_params)
          Scale an image.
static void scaleImageAbs(java.io.File p_fileIn, java.io.File p_fileOut, java.lang.Number p_numWidth, java.lang.Number p_numHeight, IMAGE_FORMAT p_imgFormat)
          Scale the given image to the given width and height.
static void scaleImageAbs(java.io.File p_fileIn, java.io.File p_fileOut, java.lang.Number p_numWidth, java.lang.Number p_numHeight, java.lang.String p_strFormat)
          Scale the given image to the given width and height.
static void scaleImageRel(java.io.File p_fileIn, java.io.File p_fileOut, java.lang.Number p_numScaleX, java.lang.Number p_numScaleY, IMAGE_FORMAT p_imgFormat)
          Scale the given image by the specified horizontal and vertical factor.
static void scaleImageRel(java.io.File p_fileIn, java.io.File p_fileOut, java.lang.Number p_numScaleX, java.lang.Number p_numScaleY, java.lang.String p_strFormat)
          Scale the given image by the specified horizontal and vertical factor.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImageFormat

public static IMAGE_FORMAT getImageFormat(java.io.File p_file)
Get the image format of the given file.

Currently the image format is derived from the file extension.

Parameters:
p_file - The image file.
Returns:
The image format, or null if it could not be derived from the file extension.

getImageFormat

public static IMAGE_FORMAT getImageFormat(java.lang.String p_strPath)
Get the image format of the given file.

Currently the image format is derived from the file extension.

Parameters:
p_strPath - The path to the image file.
Returns:
The image format, or null if it could not be derived from the file extension.

isSupportedImageFormat

public static boolean isSupportedImageFormat(java.io.File p_file)
Check if the given file has a supported image format.

Currently PNG, JPEG, and BMP are supported, and this method only checks for well-known file extensions.

Parameters:
p_file - The image file.
Returns:
true if the image format is supported, or false otherwise.

isSupportedImageFormat

public static boolean isSupportedImageFormat(java.lang.String p_strPath)
Check if the given file has a supported image format.

Currently PNG, JPEG, and BMP are supported, and this method only checks for well-known file extensions.

Parameters:
p_strPath - The path to the image file.
Returns:
true if the image format is supported, or false otherwise.

getImageSize

public static Size getImageSize(java.io.File p_file)
                         throws java.io.IOException
Determine the size of the given image.

Parameters:
p_file - The image file.
Returns:
The size of the given image.
Throws:
java.io.IOException - If an I/O error occurred, or the image file format is not supported.

getImageSize

public static Size getImageSize(java.lang.String p_strImagePath)
                         throws java.io.IOException
Determine the size of the given image.

Parameters:
p_strImagePath - The path to the image file.
Returns:
The size of the given image.
Throws:
java.io.IOException - If an I/O error occurred, or the image file format is not supported.

scaleImage

public static void scaleImage(java.util.Map<java.lang.String,java.lang.Object> p_params)
                       throws java.io.IOException
Scale an image.

Valid parameters:

Note: width, maxWidth, and scaleX are mutually exclusive; height, maxHeight, and scaleY are mutually exclusive.

Parameters:
p_params - The named parameters.
Throws:
java.io.IOException - If an I/O error occurred, or the image file format is not supported.

scaleImageAbs

public static void scaleImageAbs(java.io.File p_fileIn,
                                 java.io.File p_fileOut,
                                 java.lang.Number p_numWidth,
                                 java.lang.Number p_numHeight,
                                 IMAGE_FORMAT p_imgFormat)
                          throws java.io.IOException
Scale the given image to the given width and height.

Parameters:
p_fileIn - The input file.
p_fileOut - The output file.
p_numWidth - The new width.
p_numHeight - The new height.
p_imgFormat - The image format.
Throws:
java.io.IOException - If an I/O error occurred.

scaleImageAbs

public static void scaleImageAbs(java.io.File p_fileIn,
                                 java.io.File p_fileOut,
                                 java.lang.Number p_numWidth,
                                 java.lang.Number p_numHeight,
                                 java.lang.String p_strFormat)
                          throws java.io.IOException
Scale the given image to the given width and height.

Parameters:
p_fileIn - The input file.
p_fileOut - The output file.
p_numWidth - The new width.
p_numHeight - The new height.
p_strFormat - The format or the scaled image; i.e. 'PNG' (default), 'JPEG', or 'BMP'.
Throws:
java.io.IOException - If an I/O error occurred.

scaleImageRel

public static void scaleImageRel(java.io.File p_fileIn,
                                 java.io.File p_fileOut,
                                 java.lang.Number p_numScaleX,
                                 java.lang.Number p_numScaleY,
                                 IMAGE_FORMAT p_imgFormat)
                          throws java.io.IOException
Scale the given image by the specified horizontal and vertical factor.

Parameters:
p_fileIn - The input file.
p_fileOut - The output file.
p_numScaleX - The horizontal scaling factor.
p_numScaleY - The vertical scaling factor.
p_imgFormat - The image format.
Throws:
java.io.IOException - If an I/O error occurred.

scaleImageRel

public static void scaleImageRel(java.io.File p_fileIn,
                                 java.io.File p_fileOut,
                                 java.lang.Number p_numScaleX,
                                 java.lang.Number p_numScaleY,
                                 java.lang.String p_strFormat)
                          throws java.io.IOException
Scale the given image by the specified horizontal and vertical factor.

Parameters:
p_fileIn - The input file.
p_fileOut - The output file.
p_numScaleX - The horizontal scaling factor.
p_numScaleY - The vertical scaling factor.
p_strFormat - The format or the scaled image; i.e. 'PNG' (default), 'JPEG', or 'BMP'.
Throws:
java.io.IOException - If an I/O error occurred.


Last updated: 2011-08-11 10-04
Copyright © 2000-2011 United Planet. All Rights Reserved.