|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.core.util.thumbnail.Thumber
public class Thumber
A class to create and retrieve thumbnail of images.
| Nested Class Summary | |
|---|---|
static class |
Thumber.WidthHeightHelper
|
| Field Summary | |
|---|---|
static List<String> |
THUMBNAIL_FORMATS
|
static List<String> |
THUMBNAIL_MIME_TYPES
|
| Constructor Summary | |
|---|---|
Thumber()
Legacy compatible behaviour, all thumnails generated will be of type Thumbnail.MimeType.JPG which does not support transparency. |
|
Thumber(Thumbnail.MimeType mimeType)
Thumbnails will be generated of the given type and, if the type permits it (PNG), preserve transparency. |
|
| Method Summary | |
|---|---|
boolean |
checkToolkit()
|
Thumber.WidthHeightHelper |
determineScaleSize(int maxWidth,
int maxHeight,
int imageWidth,
int imageHeight)
|
Image |
getImage(File file)
Deprecated. since 4.6.3. Use getImage(java.io.File, com.google.common.base.Predicate) instead so that you can supply a predicate
to (for example) check that the image has reasonable dimensions that are unlikely to cause an OutOfMemoryError |
BufferedImage |
getImage(File file,
com.google.common.base.Predicate<ReusableBufferedInputStream> predicate)
Retrieves an image for the specified file if the supplied predicate is met. |
BufferedImage |
getImage(InputStream is)
Deprecated. since 4.6.3. Use getImage(com.atlassian.core.util.ReusableBufferedInputStream, com.google.common.base.Predicate)
instead so that you can supply a predicate to (for example) check that the image has reasonable dimensions that are
unlikely to cause an OutOfMemoryError |
BufferedImage |
getImage(ReusableBufferedInputStream is,
com.google.common.base.Predicate<ReusableBufferedInputStream> predicate)
Reads an image from the specified input stream if the supplied predicate is met. |
static List<String> |
getThumbnailFormats()
|
static List<String> |
getThumbnailMimeTypes()
|
boolean |
isFileSupportedImage(File file)
|
boolean |
isFileSupportedImage(InputStream inputStream)
|
Thumbnail |
retrieveOrCreateThumbNail(File originalFile,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
Retrieves an existing thumbnail, or creates a new one. |
Thumbnail |
retrieveOrCreateThumbNail(File originalFile,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId,
com.google.common.base.Predicate<Dimensions> rasterBasedRenderingPredicate)
Retrieves an existing thumbnail, or creates a new one. |
Thumbnail |
retrieveOrCreateThumbNail(InputStream originalFileStream,
String fileName,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
Retrieves an existing thumbnail, or creates a new one. |
Thumbnail |
retrieveOrCreateThumbNail(InputStream originalFileStream,
String fileName,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId,
com.google.common.base.Predicate<Dimensions> rasterBasedRenderingThreshold)
Retrieves an existing thumbnail, or creates a new one. |
BufferedImage |
scaleImage(Image imageToScale,
Thumber.WidthHeightHelper newDimensions)
This method should take BufferedImage argument, but takes just Image for backward compatibility (so that the client code can stay intact). |
BufferedImage |
scaleImageOld(Image imageToScale,
Thumber.WidthHeightHelper newDimensions)
Deprecated. |
void |
setEncodingQuality(float f)
Set the default encoding quality used by the thumber to encode jpegs. |
void |
storeImage(BufferedImage scaledImage,
File file)
Store Image in format defined by constructor |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final List<String> THUMBNAIL_MIME_TYPES
public static final List<String> THUMBNAIL_FORMATS
| Constructor Detail |
|---|
public Thumber()
Thumbnail.MimeType.JPG which does not support transparency.
public Thumber(Thumbnail.MimeType mimeType)
mimeType - the type of all thumbnails generated and retrieved.| Method Detail |
|---|
public static List<String> getThumbnailMimeTypes()
public static List<String> getThumbnailFormats()
public boolean checkToolkit()
public Thumbnail retrieveOrCreateThumbNail(File originalFile,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
throws MalformedURLException
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.
MalformedURLException
public Thumbnail retrieveOrCreateThumbNail(File originalFile,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId,
com.google.common.base.Predicate<Dimensions> rasterBasedRenderingPredicate)
throws MalformedURLException
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.
MalformedURLException
public void storeImage(BufferedImage scaledImage,
File file)
throws FileNotFoundException
scaledImage - file -
FileNotFoundException
public BufferedImage scaleImage(Image imageToScale,
Thumber.WidthHeightHelper newDimensions)
imageToScale - image to scale (BufferedImage is welcome, other image types will be transformed to
BufferedImage first)newDimensions - desired max. dimensions
@Deprecated
public BufferedImage scaleImageOld(Image imageToScale,
Thumber.WidthHeightHelper newDimensions)
scaleImage(java.awt.Image, com.atlassian.core.util.thumbnail.Thumber.WidthHeightHelper) instead
imageToScale - input imagenewDimensions - desired max. dimensions (the ratio will be kept)
public Thumbnail retrieveOrCreateThumbNail(InputStream originalFileStream,
String fileName,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId)
throws MalformedURLException
originalFileStream - The image streamfileName - Filename for specified imagethumbnailFile - 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.
MalformedURLException
public Thumbnail retrieveOrCreateThumbNail(InputStream originalFileStream,
String fileName,
File thumbnailFile,
int maxWidth,
int maxHeight,
long thumbnailId,
com.google.common.base.Predicate<Dimensions> rasterBasedRenderingThreshold)
originalFileStream - The image streamfileName - Filename for specified imagethumbnailFile - 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.
public Image getImage(File file)
throws IOException
getImage(java.io.File, com.google.common.base.Predicate) instead so that you can supply a predicate
to (for example) check that the image has reasonable dimensions that are unlikely to cause an OutOfMemoryError
IOException
public BufferedImage getImage(File file,
@Nonnull
com.google.common.base.Predicate<ReusableBufferedInputStream> predicate)
throws IOException
file - File to read an image frompredicate - Predicate that needs to be met before attempting to read an image from the file (e.g. image
dimensions that shouldn't be exceeded)
FailedPredicateException - If predicate was supplied but not met
IOException
public BufferedImage getImage(InputStream is)
throws IOException
getImage(com.atlassian.core.util.ReusableBufferedInputStream, com.google.common.base.Predicate)
instead so that you can supply a predicate to (for example) check that the image has reasonable dimensions that are
unlikely to cause an OutOfMemoryError
IOException
public BufferedImage getImage(ReusableBufferedInputStream is,
@Nonnull
com.google.common.base.Predicate<ReusableBufferedInputStream> predicate)
throws IOException
is - Input stream to read an image frompredicate - Predicate that needs to be met before attempting to read an image from the file (e.g. image
dimensions that shouldn't be exceeded)
FailedPredicateException - If predicate was supplied but not met
IOExceptionpublic void setEncodingQuality(float f)
public Thumber.WidthHeightHelper determineScaleSize(int maxWidth,
int maxHeight,
int imageWidth,
int imageHeight)
public boolean isFileSupportedImage(File file)
public boolean isFileSupportedImage(InputStream inputStream)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||