magoffin.matt.ma2.image.jmagick
Class ScaleEffect

java.lang.Object
  extended by magoffin.matt.ma2.image.jmagick.BaseJMagickMediaEffect
      extended by magoffin.matt.ma2.image.jmagick.ScaleEffect
All Implemented Interfaces:
JMagickMediaEffect, MediaEffect

public class ScaleEffect
extends BaseJMagickMediaEffect

Effect that scales an image to the size specified on the request.

Different scaling algorithms can be specified for thumbnail and non-thumbnail sized images, with the idea that thumbnails could use a faster (but uglier) algorithm while non-thumbnails could use a slower (but prettier) one. By default the thumbnail algorithm is set to triangle and the non-thumbnail algorithm is sinc.

Note this effect assumes a rotate effect has not been applied before this effect is applied.

The configurable properties of this class are:

filterNameMap
A mapping of filter names to FilterType constant values. This map is populated by default with each FilterType constant name, minus the "Filter" ending. For example the FilterType.BesselFilter constant is named Bessel.
thumbnailFilterName
The filter name to use for thumbnail-sized images. Defaults to DEFAULT_THUMBNAIL_FILTER_NAME
normalFilterName
The filter name to use for non-thumbnail-sized images. Defaults to DEFAULT_NORMAL_FILTER_NAME.
thumbnailSizes
A set of MediaSize for which to treat as thumbnail sizes and scale with the thumbnailFilterName as opposed to the normalFilterName. Defaults to a set containing MediaSize.THUMB_SMALL, MediaSize.THUMB_NORMAL, and MediaSize.THUMB_BIG. The MediaSize.THUMB_BIGGER is intentionally left out so that the normalFilterName will be used for this size to achieve higher quality.

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Field Summary
static java.lang.String DEFAULT_NORMAL_FILTER_NAME
          The default value for the normalFilterName property.
static java.lang.String DEFAULT_THUMBNAIL_FILTER_NAME
          The default value for the thumbnailFilterName property.
static java.lang.String SCALE_KEY
          The key for this effect.
 
Fields inherited from class magoffin.matt.ma2.image.jmagick.BaseJMagickMediaEffect
log
 
Fields inherited from interface magoffin.matt.ma2.image.jmagick.JMagickMediaEffect
INPUT_IMAGE_INFO_KEY, INPUT_MAGICK_IMAGE_KEY, OUTPUT_MAGICK_IMAGE_KEY
 
Fields inherited from interface magoffin.matt.ma2.MediaEffect
KEY_ROTATE, KEY_SCALE, KEY_WATERMARK, MEDIA_REQUEST_PARAM_ROTATE_DEGREES, MEDIA_REQUEST_PARAM_WATERMARK_RESOURCE
 
Constructor Summary
ScaleEffect()
          Constructor.
 
Method Summary
 magick.MagickImage applyEffect(MediaItem item, MediaRequest request, magick.ImageInfo inInfo, magick.MagickImage image)
          Apply effect with ImageMagick.
protected  java.util.Map<java.lang.String,java.lang.Integer> getFilterNameMap()
           
 java.lang.String getKey()
          Get the key for this effect.
protected  java.lang.String getNormalFilterName()
           
protected  java.lang.String getThumbnailFilterName()
           
protected  java.util.Set<MediaSize> getThumbnailSizes()
           
protected  void setFilterNameMap(java.util.Map<java.lang.String,java.lang.Integer> filterNameMap)
           
protected  void setNormalFilterName(java.lang.String normalFilterName)
           
protected  void setThumbnailFilterName(java.lang.String thumbnailFilterName)
           
protected  void setThumbnailSizes(java.util.Set<MediaSize> thumbnailSizes)
           
 
Methods inherited from class magoffin.matt.ma2.image.jmagick.BaseJMagickMediaEffect
apply, getMediaBiz, setMediaBiz
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_THUMBNAIL_FILTER_NAME

public static final java.lang.String DEFAULT_THUMBNAIL_FILTER_NAME
The default value for the thumbnailFilterName property.

See Also:
Constant Field Values

DEFAULT_NORMAL_FILTER_NAME

public static final java.lang.String DEFAULT_NORMAL_FILTER_NAME
The default value for the normalFilterName property.

See Also:
Constant Field Values

SCALE_KEY

public static final java.lang.String SCALE_KEY
The key for this effect.

See Also:
Constant Field Values
Constructor Detail

ScaleEffect

public ScaleEffect()
Constructor.

Method Detail

applyEffect

public magick.MagickImage applyEffect(MediaItem item,
                                      MediaRequest request,
                                      magick.ImageInfo inInfo,
                                      magick.MagickImage image)
Description copied from interface: JMagickMediaEffect
Apply effect with ImageMagick.

Parameters:
item - the MediaItem the effect is being applied to
request - the request
inInfo - the ImageInfo used to open the image
image - the current ImageMagick MagickImage
Returns:
the resulting image

getKey

public java.lang.String getKey()
Description copied from interface: MediaEffect
Get the key for this effect.

Keys uniquely describe the implementation and function of the effect. The implementation key should come first, and the function key at the end. Some standard function key values are defined in this API: MediaEffect.KEY_SCALE for re-sizing and MediaEffect.KEY_ROTATE for rotating.

For example, a key might look like image.awt.rotate for an image rotation effect based on a Java AWT implementation.

Returns:
the effect key

getFilterNameMap

protected java.util.Map<java.lang.String,java.lang.Integer> getFilterNameMap()
Returns:
the filterNameMap

setFilterNameMap

protected void setFilterNameMap(java.util.Map<java.lang.String,java.lang.Integer> filterNameMap)
Parameters:
filterNameMap - the filterNameMap to set

getThumbnailFilterName

protected java.lang.String getThumbnailFilterName()
Returns:
the thumbnailFilterName

setThumbnailFilterName

protected void setThumbnailFilterName(java.lang.String thumbnailFilterName)
Parameters:
thumbnailFilterName - the thumbnailFilterName to set

getNormalFilterName

protected java.lang.String getNormalFilterName()
Returns:
the normalFilterName

setNormalFilterName

protected void setNormalFilterName(java.lang.String normalFilterName)
Parameters:
normalFilterName - the normalFilterName to set

getThumbnailSizes

protected java.util.Set<MediaSize> getThumbnailSizes()
Returns:
the thumbnailSizes

setThumbnailSizes

protected void setThumbnailSizes(java.util.Set<MediaSize> thumbnailSizes)
Parameters:
thumbnailSizes - the thumbnailSizes to set