@ProviderType
public class ImageToolUtil
extends Object
Constructor and Description |
---|
ImageToolUtil() |
Modifier and Type | Method and Description |
---|---|
static Future<RenderedImage> |
convertCMYKtoRGB(byte[] bytes,
String type)
Returns the CMYK image converted to RGB using ImageMagick.
|
static BufferedImage |
convertImageType(BufferedImage sourceImage,
int type)
Returns the image converted to the type.
|
static RenderedImage |
crop(RenderedImage renderedImage,
int height,
int width,
int x,
int y) |
static void |
encodeGIF(RenderedImage renderedImage,
OutputStream os)
Encodes the image using the GIF format.
|
static void |
encodeWBMP(RenderedImage renderedImage,
OutputStream os)
Encodes the image using the WBMP format.
|
static RenderedImage |
flipHorizontal(RenderedImage renderedImage) |
static RenderedImage |
flipVertical(RenderedImage renderedImage) |
static BufferedImage |
getBufferedImage(RenderedImage renderedImage)
Returns the rendered image as a
BufferedImage . |
static byte[] |
getBytes(RenderedImage renderedImage,
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(File file) |
static Image |
getImage(InputStream is) |
static Image |
getImage(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(File file)
Detects the image format and creates an
ImageBag containing the
RenderedImage and image type. |
static ImageBag |
read(InputStream inputStream) |
static RenderedImage |
rotate(RenderedImage renderedImage,
int degrees) |
static RenderedImage |
scale(RenderedImage renderedImage,
int width)
Returns the scaled image based on the given width with the height
calculated to preserve aspect ratio.
|
static RenderedImage |
scale(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(RenderedImage renderedImage,
String contentType,
OutputStream os)
Encodes the image using the content or image type.
|
public static Future<RenderedImage> convertCMYKtoRGB(byte[] bytes, 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 BufferedImage convertImageType(BufferedImage sourceImage, int type)
sourceImage
- the image to converttype
- the image type to convert to (e.g., "gif", "jpg", etc.)public static RenderedImage crop(RenderedImage renderedImage, int height, int width, int x, int y)
public static void encodeGIF(RenderedImage renderedImage, OutputStream os) throws IOException
renderedImage
- the image to encodeos
- the stream to write toIOException
- if an IO exception occurredpublic static void encodeWBMP(RenderedImage renderedImage, OutputStream os) throws IOException
renderedImage
- the image to encodeos
- the stream to write toIOException
- if an IO exception occurredpublic static RenderedImage flipHorizontal(RenderedImage renderedImage)
public static RenderedImage flipVertical(RenderedImage renderedImage)
public static BufferedImage getBufferedImage(RenderedImage renderedImage)
BufferedImage
.renderedImage
- the original imagepublic static byte[] getBytes(RenderedImage renderedImage, String contentType) throws IOException
byte[]
.renderedImage
- the image to readcontentType
- the content type (e.g., "image/jpeg") or image type
(e.g., "jpg") to use during encodingIOException
- 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, IOException
ImageResolutionException
IOException
public static Image getImage(File file) throws ImageResolutionException, IOException
ImageResolutionException
IOException
public static Image getImage(InputStream is) throws ImageResolutionException, IOException
ImageResolutionException
IOException
public static Image getImage(InputStream is, boolean cleanUpStream) throws ImageResolutionException, IOException
ImageResolutionException
IOException
public static ImageTool getImageTool()
public static boolean isNullOrDefaultSpacer(byte[] bytes)
public static ImageBag read(byte[] bytes) throws ImageResolutionException, 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
IOException
- if an IO exception occurredpublic static ImageBag read(File file) throws ImageResolutionException, 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
IOException
- if an IO exception occurredpublic static ImageBag read(InputStream inputStream) throws ImageResolutionException, IOException
ImageResolutionException
IOException
public static RenderedImage rotate(RenderedImage renderedImage, int degrees)
public static RenderedImage scale(RenderedImage renderedImage, int width)
renderedImage
- the image to scalewidth
- the new width; also used to calculate the new heightpublic static RenderedImage scale(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(RenderedImage renderedImage, String contentType, OutputStream os) throws 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 toIOException
- if an IO exception occurredpublic void setImageTool(ImageTool imageTool)