com.liferay.portal.kernel.image
Interface ImageTool


public interface ImageTool

Author:
Brian Wing Shun Chan

Field Summary
static java.lang.String TYPE_BMP
           
static java.lang.String TYPE_GIF
           
static java.lang.String TYPE_JPEG
           
static java.lang.String TYPE_NOT_AVAILABLE
           
static java.lang.String TYPE_PNG
           
static java.lang.String TYPE_TIFF
           
 
Method Summary
 java.awt.image.BufferedImage convertImageType(java.awt.image.BufferedImage sourceImage, int type)
           
 void encodeGIF(java.awt.image.RenderedImage renderedImage, java.io.OutputStream os)
           
 void encodeWBMP(java.awt.image.RenderedImage renderedImage, java.io.OutputStream os)
           
 java.awt.image.BufferedImage getBufferedImage(java.awt.image.RenderedImage renderedImage)
           
 byte[] getBytes(java.awt.image.RenderedImage renderedImage, java.lang.String contentType)
           
 ImageBag read(byte[] bytes)
           
 ImageBag read(java.io.File file)
           
 java.awt.image.RenderedImage scale(java.awt.image.RenderedImage renderedImage, int width)
          Scales the image based on the given width with the height calculated to preserve aspect ratio.
 java.awt.image.RenderedImage scale(java.awt.image.RenderedImage renderedImage, int maxHeight, int maxWidth)
          Scales the image based on the maximum height and width given while preserving the aspect ratio.
 void write(java.awt.image.RenderedImage renderedImage, java.lang.String contentType, java.io.OutputStream os)
           
 

Field Detail

TYPE_BMP

static final java.lang.String TYPE_BMP
See Also:
Constant Field Values

TYPE_GIF

static final java.lang.String TYPE_GIF
See Also:
Constant Field Values

TYPE_JPEG

static final java.lang.String TYPE_JPEG
See Also:
Constant Field Values

TYPE_NOT_AVAILABLE

static final java.lang.String TYPE_NOT_AVAILABLE
See Also:
Constant Field Values

TYPE_PNG

static final java.lang.String TYPE_PNG
See Also:
Constant Field Values

TYPE_TIFF

static final java.lang.String TYPE_TIFF
See Also:
Constant Field Values
Method Detail

convertImageType

java.awt.image.BufferedImage convertImageType(java.awt.image.BufferedImage sourceImage,
                                              int type)

encodeGIF

void encodeGIF(java.awt.image.RenderedImage renderedImage,
               java.io.OutputStream os)
               throws java.io.IOException
Throws:
java.io.IOException

encodeWBMP

void encodeWBMP(java.awt.image.RenderedImage renderedImage,
                java.io.OutputStream os)
                throws java.lang.InterruptedException,
                       java.io.IOException
Throws:
java.lang.InterruptedException
java.io.IOException

getBufferedImage

java.awt.image.BufferedImage getBufferedImage(java.awt.image.RenderedImage renderedImage)

getBytes

byte[] getBytes(java.awt.image.RenderedImage renderedImage,
                java.lang.String contentType)
                throws java.io.IOException
Throws:
java.io.IOException

read

ImageBag read(byte[] bytes)
              throws java.io.IOException
Throws:
java.io.IOException

read

ImageBag read(java.io.File file)
              throws java.io.IOException
Throws:
java.io.IOException

scale

java.awt.image.RenderedImage scale(java.awt.image.RenderedImage renderedImage,
                                   int width)
Scales the image based on the given width with the height calculated to preserve aspect ratio.

Parameters:
renderedImage - image to scale
width - used as new width and to calculate for new height
Returns:
scaled image

scale

java.awt.image.RenderedImage scale(java.awt.image.RenderedImage renderedImage,
                                   int maxHeight,
                                   int maxWidth)
Scales the image based on the maximum height and width given while preserving the aspect ratio. If the image is already larger in both dimensions, the image will not be scaled.

Parameters:
renderedImage - image to scale
maxHeight - maximum height allowed for image
maxWidth - maximum width allowed for image
Returns:
scaled image

write

void write(java.awt.image.RenderedImage renderedImage,
           java.lang.String contentType,
           java.io.OutputStream os)
           throws java.io.IOException
Throws:
java.io.IOException