|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.liferay.portal.kernel.image.ImageToolUtil
public class ImageToolUtil
The Image utility class.
| Constructor Summary | |
|---|---|
ImageToolUtil()
|
|
| Method Summary | |
|---|---|
static java.util.concurrent.Future<java.awt.image.RenderedImage> |
convertCMYKtoRGB(byte[] bytes,
java.lang.String type)
Returns the CMYK image converted to RGB using ImageMagick. |
static java.awt.image.BufferedImage |
convertImageType(java.awt.image.BufferedImage sourceImage,
int type)
Returns the image converted to the type. |
static void |
encodeGIF(java.awt.image.RenderedImage renderedImage,
java.io.OutputStream os)
Encodes the image using the GIF format. |
static void |
encodeWBMP(java.awt.image.RenderedImage renderedImage,
java.io.OutputStream os)
Encodes the image using the WBMP format. |
static java.awt.image.BufferedImage |
getBufferedImage(java.awt.image.RenderedImage renderedImage)
Returns the rendered image as a BufferedImage. |
static byte[] |
getBytes(java.awt.image.RenderedImage renderedImage,
java.lang.String contentType)
Returns the image as a byte[]. |
static Image |
getDefaultCompanyLogo()
|
static Image |
getDefaultOrganizationLogo()
|
static Image |
getDefaultSpacer()
|
static Image |
getDefaultUserFemalePortrait()
|
static Image |
getDefaultUserMalePortrait()
|
static Image |
getImage(byte[] bytes)
|
static Image |
getImage(java.io.File file)
|
static Image |
getImage(java.io.InputStream is)
|
static Image |
getImage(java.io.InputStream is,
boolean cleanUpStream)
|
static ImageTool |
getImageTool()
|
static boolean |
isNullOrDefaultSpacer(byte[] bytes)
|
static ImageBag |
read(byte[] bytes)
Detects the image format and creates an ImageBag containing the RenderedImage and image type. |
static ImageBag |
read(java.io.File file)
Detects the image format and creates an ImageBag containing the RenderedImage and image type. |
static ImageBag |
read(java.io.InputStream inputStream)
|
static java.awt.image.RenderedImage |
scale(java.awt.image.RenderedImage renderedImage,
int width)
Returns the scaled image based on the given width with the height calculated to preserve aspect ratio. |
static java.awt.image.RenderedImage |
scale(java.awt.image.RenderedImage renderedImage,
int maxHeight,
int maxWidth)
Returns the scaled image based on the maximum height and width given while preserving the aspect ratio. |
void |
setImageTool(ImageTool imageTool)
|
static void |
write(java.awt.image.RenderedImage renderedImage,
java.lang.String contentType,
java.io.OutputStream os)
Encodes the image using the content or image type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ImageToolUtil()
| Method Detail |
|---|
public static java.util.concurrent.Future<java.awt.image.RenderedImage> convertCMYKtoRGB(byte[] bytes,
java.lang.String type)
byte[] and not one extracted from a
RenderedImage. The latter may potentially have
been already been read incorrectly.
bytes - the image to converttype - the image type (e.g., "gif", "jpg", etc.)
null
if ImageMagick was disabled or if the conversion could
not be completed. The conversion may not complete if (1) the
image was not in the CMYK colorspace to begin with or (2) there
was an error in the conversion process.
public static java.awt.image.BufferedImage convertImageType(java.awt.image.BufferedImage sourceImage,
int type)
sourceImage - the image to converttype - the image type to convert to (e.g., "gif", "jpg", etc.)
public static void encodeGIF(java.awt.image.RenderedImage renderedImage,
java.io.OutputStream os)
throws java.io.IOException
renderedImage - the image to encodeos - the stream to write to
java.io.IOException - if an IO exception occurred
public static void encodeWBMP(java.awt.image.RenderedImage renderedImage,
java.io.OutputStream os)
throws java.io.IOException
renderedImage - the image to encodeos - the stream to write to
java.io.IOException - if an IO exception occurredpublic static java.awt.image.BufferedImage getBufferedImage(java.awt.image.RenderedImage renderedImage)
BufferedImage.
renderedImage - the original image
public static byte[] getBytes(java.awt.image.RenderedImage renderedImage,
java.lang.String contentType)
throws java.io.IOException
byte[].
renderedImage - the image to readcontentType - the content type (e.g., "image/jpeg") or image type
(e.g., "jpg") to use during encoding
java.io.IOException - if an IO exception occurredpublic static Image getDefaultCompanyLogo()
public static Image getDefaultOrganizationLogo()
public static Image getDefaultSpacer()
public static Image getDefaultUserFemalePortrait()
public static Image getDefaultUserMalePortrait()
public static Image getImage(byte[] bytes)
throws java.io.IOException
java.io.IOException
public static Image getImage(java.io.File file)
throws java.io.IOException
java.io.IOException
public static Image getImage(java.io.InputStream is)
throws java.io.IOException
java.io.IOException
public static Image getImage(java.io.InputStream is,
boolean cleanUpStream)
throws java.io.IOException
java.io.IOExceptionpublic static ImageTool getImageTool()
public static boolean isNullOrDefaultSpacer(byte[] bytes)
public static ImageBag read(byte[] bytes)
throws java.io.IOException
ImageBag containing the RenderedImage and image type.
bytes - the bytes to read
ImageBag
java.io.IOException - if an IO exception occurred
public static ImageBag read(java.io.File file)
throws java.io.IOException
ImageBag containing the RenderedImage and image type.
file - the file to read
ImageBag
java.io.IOException - if an IO exception occurred
public static ImageBag read(java.io.InputStream inputStream)
throws java.io.IOException
java.io.IOException
public static java.awt.image.RenderedImage scale(java.awt.image.RenderedImage renderedImage,
int width)
renderedImage - the image to scalewidth - the new width; also used to calculate the new height
public static java.awt.image.RenderedImage scale(java.awt.image.RenderedImage renderedImage,
int maxHeight,
int maxWidth)
renderedImage - the image to scalemaxHeight - the maximum height allowed for imagemaxWidth - the maximum width allowed for image
public static void write(java.awt.image.RenderedImage renderedImage,
java.lang.String contentType,
java.io.OutputStream os)
throws java.io.IOException
renderedImage - the image to encodecontentType - the content type (e.g., "image/jpeg") or image type
(e.g., "jpg") to use during encodingos - the stream to write to
java.io.IOException - if an IO exception occurredpublic void setImageTool(ImageTool imageTool)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||