com.atlassian.core.util.thumbnail
Class Thumber
java.lang.Object
com.atlassian.core.util.thumbnail.Thumber
- public class Thumber
- extends java.lang.Object
A class to create and retrieve thumbnail of images.
|
Method Summary |
boolean |
checkToolkit()
|
Thumber.WidthHeightHelper |
determineScaleSize(int maxWidth,
int maxHeight,
int imageWidth,
int imageHeight)
|
java.awt.Image |
getImage(java.io.File file)
|
java.awt.Image |
getImage(java.io.InputStream is)
|
boolean |
isFileSupportedImage(java.io.File file)
|
boolean |
isFileSupportedImage(java.io.InputStream inputStream)
|
Thumbnail |
retrieveOrCreateThumbNail(java.io.File originalFile,
java.io.File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
Retrieves an existing thumbnail, or creates a new one. |
Thumbnail |
retrieveOrCreateThumbNail(java.io.InputStream originalFileStream,
java.lang.String fileName,
java.io.File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
Need to pass filename in as we cannot get the filename from the stream that is passed in |
java.awt.image.BufferedImage |
scaleImage(java.awt.Image imageToScale,
Thumber.WidthHeightHelper newDimensions)
|
void |
setEncodingQuality(float f)
Set the default encoding quality used by the thumber to encode jpegs. |
void |
storeImage(java.awt.image.BufferedImage scaledImage,
java.io.File file)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JPEG_MIME_TYPE
public static final java.lang.String JPEG_MIME_TYPE
- See Also:
- Constant Field Values
PNG_MIME_TYPE
public static final java.lang.String PNG_MIME_TYPE
- See Also:
- Constant Field Values
GIF_MIME_TYPE
public static final java.lang.String GIF_MIME_TYPE
- See Also:
- Constant Field Values
THUMBNAIL_MIME_TYPES
public static final java.util.List THUMBNAIL_MIME_TYPES
JPEG_FORMAT
public static final java.lang.String JPEG_FORMAT
- See Also:
- Constant Field Values
PNG_FORMAT
public static final java.lang.String PNG_FORMAT
- See Also:
- Constant Field Values
GIF_FORMAT
public static final java.lang.String GIF_FORMAT
- See Also:
- Constant Field Values
THUMBNAIL_FORMATS
public static final java.util.List THUMBNAIL_FORMATS
Thumber
public Thumber()
checkToolkit
public boolean checkToolkit()
- Returns:
- True if the AWT default toolkit exists, false (with an error logged) if it does not.
retrieveOrCreateThumbNail
public Thumbnail retrieveOrCreateThumbNail(java.io.File originalFile,
java.io.File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
throws java.net.MalformedURLException
- Retrieves an existing thumbnail, or creates a new one.
- Parameters:
originalFile - The file which is being thumbnailed.thumbnailFile - The location of the existing thumbnail (if it exists), or the location to create a new thumbnail.maxWidth - The max width of the thumbnail.maxHeight - The max height of the thumbnail.thumbnailId -
- Returns:
-
- Throws:
java.net.MalformedURLException
storeImage
public void storeImage(java.awt.image.BufferedImage scaledImage,
java.io.File file)
throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
scaleImage
public java.awt.image.BufferedImage scaleImage(java.awt.Image imageToScale,
Thumber.WidthHeightHelper newDimensions)
retrieveOrCreateThumbNail
public Thumbnail retrieveOrCreateThumbNail(java.io.InputStream originalFileStream,
java.lang.String fileName,
java.io.File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
throws java.net.MalformedURLException
- Need to pass filename in as we cannot get the filename from the stream that is passed in
- Parameters:
originalFileStream - fileName - thumbnailFile - maxWidth - maxHeight - thumbnailId -
- Returns:
- a Thumbnail instance or null if an error occured
- Throws:
java.net.MalformedURLException
getImage
public java.awt.Image getImage(java.io.File file)
throws java.io.IOException
- Parameters:
file -
- Returns:
- An Image object or null if there was no suitable ImageReader for the given data
- Throws:
java.io.IOException
getImage
public java.awt.Image getImage(java.io.InputStream is)
throws java.io.IOException
- Parameters:
is -
- Returns:
- An Image object or null if there was no suitable ImageReader for the given data
- Throws:
java.io.IOException
setEncodingQuality
public void setEncodingQuality(float f)
- Set the default encoding quality used by the thumber to encode jpegs.
- Parameters:
f -
determineScaleSize
public Thumber.WidthHeightHelper determineScaleSize(int maxWidth,
int maxHeight,
int imageWidth,
int imageHeight)
isFileSupportedImage
public boolean isFileSupportedImage(java.io.File file)
isFileSupportedImage
public boolean isFileSupportedImage(java.io.InputStream inputStream)
Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.