public class ImageToolUtil
extends java.lang.Object
Constructor and Description |
---|
ImageToolUtil() |
Modifier and Type | Method and Description |
---|---|
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 java.awt.image.RenderedImage |
crop(java.awt.image.RenderedImage renderedImage,
int height,
int width,
int x,
int y) |
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.RenderedImage |
flipHorizontal(java.awt.image.RenderedImage renderedImage) |
static java.awt.image.RenderedImage |
flipVertical(java.awt.image.RenderedImage renderedImage) |
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 |
rotate(java.awt.image.RenderedImage renderedImage,
int degrees) |
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.
|
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 java.awt.image.RenderedImage crop(java.awt.image.RenderedImage renderedImage, int height, int width, int x, int y)
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 tojava.io.IOException
- if an IO exception occurredpublic 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 tojava.io.IOException
- if an IO exception occurredpublic static java.awt.image.RenderedImage flipHorizontal(java.awt.image.RenderedImage renderedImage)
public static java.awt.image.RenderedImage flipVertical(java.awt.image.RenderedImage renderedImage)
public static java.awt.image.BufferedImage getBufferedImage(java.awt.image.RenderedImage renderedImage)
BufferedImage
.renderedImage
- the original imagepublic 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 encodingjava.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 ImageResolutionException, java.io.IOException
ImageResolutionException
java.io.IOException
public static Image getImage(java.io.File file) throws ImageResolutionException, java.io.IOException
ImageResolutionException
java.io.IOException
public static Image getImage(java.io.InputStream is) throws ImageResolutionException, java.io.IOException
ImageResolutionException
java.io.IOException
public static Image getImage(java.io.InputStream is, boolean cleanUpStream) throws ImageResolutionException, java.io.IOException
ImageResolutionException
java.io.IOException
public static ImageTool getImageTool()
public static boolean isNullOrDefaultSpacer(byte[] bytes)
public static ImageBag read(byte[] bytes) throws ImageResolutionException, java.io.IOException
ImageBag
containing the
RenderedImage
and image type.bytes
- the bytes to readImageBag
ImageResolutionException
- if the image's dimensions were larger
than those specified by portal properties
image.tool.image.max.height
and
image.tool.image.max.width
java.io.IOException
- if an IO exception occurredpublic static ImageBag read(java.io.File file) throws ImageResolutionException, java.io.IOException
ImageBag
containing the
RenderedImage
and image type.file
- the file to readImageBag
ImageResolutionException
- if the image's dimensions were larger
than those specified by portal properties
image.tool.image.max.height
and
image.tool.image.max.width
java.io.IOException
- if an IO exception occurredpublic static ImageBag read(java.io.InputStream inputStream) throws ImageResolutionException, java.io.IOException
ImageResolutionException
java.io.IOException
public static java.awt.image.RenderedImage rotate(java.awt.image.RenderedImage renderedImage, int degrees)
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 heightpublic 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 imagepublic 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 tojava.io.IOException
- if an IO exception occurredpublic void setImageTool(ImageTool imageTool)