org.alfresco.repo.content.transform.magick
Class AbstractImageMagickContentTransformerWorker

java.lang.Object
  extended by org.alfresco.repo.content.transform.ContentTransformerHelper
      extended by org.alfresco.repo.content.transform.magick.AbstractImageMagickContentTransformerWorker
All Implemented Interfaces:
ContentTransformerWorker, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
ImageMagickContentTransformerWorker

public abstract class AbstractImageMagickContentTransformerWorker
extends ContentTransformerHelper
implements ContentTransformerWorker, org.springframework.beans.factory.InitializingBean

Abstract helper for transformations based on ImageMagick


Field Summary
static java.lang.String MIMETYPE_IMAGE_PREFIX
          the prefix for mimetypes supported by the transformer
 
Constructor Summary
AbstractImageMagickContentTransformerWorker()
           
 
Method Summary
 void afterPropertiesSet()
          Checks for the JMagick and ImageMagick dependencies, using the common transformation method to check that the sample image can be converted.
 boolean isAvailable()
          Checks if this worker is available.
static boolean isSupported(java.lang.String mimetype)
          Some image formats are not supported by ImageMagick, or at least appear not to work.
 boolean isTransformable(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
          Supports image to image conversion, but only if the JMagick library and required libraries are available.
protected  void setAvailable(boolean available)
          Make the transformer available
 void transform(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)
           
protected abstract  void transformInternal(java.io.File sourceFile, java.io.File targetFile, TransformationOptions options)
          Transform the image content from the source file to the target file
 
Methods inherited from class org.alfresco.repo.content.transform.ContentTransformerHelper
getMimetype, getMimetypeService, isExplicitTransformation, setExplicitTransformations, setMimetypeService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.alfresco.repo.content.transform.ContentTransformerWorker
getVersionString
 

Field Detail

MIMETYPE_IMAGE_PREFIX

public static final java.lang.String MIMETYPE_IMAGE_PREFIX
the prefix for mimetypes supported by the transformer

See Also:
Constant Field Values
Constructor Detail

AbstractImageMagickContentTransformerWorker

public AbstractImageMagickContentTransformerWorker()
Method Detail

isAvailable

public boolean isAvailable()
Description copied from interface: ContentTransformerWorker
Checks if this worker is available.

Specified by:
isAvailable in interface ContentTransformerWorker
Returns:
Returns true if the transformer is functioning otherwise false

setAvailable

protected void setAvailable(boolean available)
Make the transformer available

Parameters:
available -

afterPropertiesSet

public void afterPropertiesSet()
Checks for the JMagick and ImageMagick dependencies, using the common transformation method to check that the sample image can be converted.

If initialization is successful, then autoregistration takes place.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

isSupported

public static boolean isSupported(java.lang.String mimetype)
Some image formats are not supported by ImageMagick, or at least appear not to work.

Parameters:
mimetype - the mimetype to check
Returns:
Returns true if ImageMagic can handle the given image format

isTransformable

public boolean isTransformable(java.lang.String sourceMimetype,
                               java.lang.String targetMimetype,
                               TransformationOptions options)
Supports image to image conversion, but only if the JMagick library and required libraries are available.

Specified by:
isTransformable in interface ContentTransformerWorker
See Also:
ContentTransformer.isTransformable(String, String, TransformationOptions)

transform

public final void transform(org.alfresco.service.cmr.repository.ContentReader reader,
                            org.alfresco.service.cmr.repository.ContentWriter writer,
                            TransformationOptions options)
                     throws java.lang.Exception
Specified by:
transform in interface ContentTransformerWorker
Throws:
java.lang.Exception
See Also:
#transformInternal(File, File)

transformInternal

protected abstract void transformInternal(java.io.File sourceFile,
                                          java.io.File targetFile,
                                          TransformationOptions options)
                                   throws java.lang.Exception
Transform the image content from the source file to the target file

Parameters:
sourceFile - the source of the transformation
targetFile - the target of the transformation
options - the transformation options supported by ImageMagick
Throws:
java.lang.Exception


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.