com.atlassian.core.util.thumbnail
Class Thumber

java.lang.Object
  extended by com.atlassian.core.util.thumbnail.Thumber

public class Thumber
extends java.lang.Object

A class to create and retrieve thumbnail of images.


Nested Class Summary
static class Thumber.WidthHeightHelper
           
 
Field Summary
static java.util.List<java.lang.String> THUMBNAIL_FORMATS
           
static java.util.List<java.lang.String> THUMBNAIL_MIME_TYPES
           
 
Constructor Summary
Thumber()
           
 
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)
           
static java.util.List<java.lang.String> getThumbnailFormats()
           
static java.util.List<java.lang.String> getThumbnailMimeTypes()
           
 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
 

Field Detail

THUMBNAIL_MIME_TYPES

public static final java.util.List<java.lang.String> THUMBNAIL_MIME_TYPES

THUMBNAIL_FORMATS

public static final java.util.List<java.lang.String> THUMBNAIL_FORMATS
Constructor Detail

Thumber

public Thumber()
Method Detail

getThumbnailMimeTypes

public static java.util.List<java.lang.String> getThumbnailMimeTypes()

getThumbnailFormats

public static java.util.List<java.lang.String> getThumbnailFormats()

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 © 2009 Atlassian Pty Ltd. All Rights Reserved.