com.day.cq.dam.commons.util
Class WebEnabledImageCreator

java.lang.Object
  extended by com.day.cq.dam.commons.util.WebEnabledImageCreator

public class WebEnabledImageCreator
extends Object

The WebEnabledImageCreator class provides all functionality in order to create a web enabled image.


Constructor Summary
WebEnabledImageCreator(Asset asset, MimeTypeService mimeTypeService)
           
 
Method Summary
 void create(BufferedImage image, String defaultMimetype, String dimensions, String keepFormat, String qualityStr, boolean force)
          This method creates the web enabled rendition. if the force param is set to false than following check is executed: check if layer has to persisted. in case the layer is still equal than the ori file can be taken (save space).
protected  Layer createImage(BufferedImage image, int maxWidth, int maxHeight)
          A image with the given maxWith and maxHeight is generated out if the image source.
protected  Integer[] getDimension(String dimensions)
           
protected  String getExtension(String mimetype)
           
protected  String getMimeType(Asset asset)
           
protected  double getQuality(double base, String qualityStr)
           
protected  void saveImage(Asset asset, Layer layer, String mimetype, double quality, String renditionName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebEnabledImageCreator

public WebEnabledImageCreator(Asset asset,
                              MimeTypeService mimeTypeService)
Method Detail

create

public void create(BufferedImage image,
                   String defaultMimetype,
                   String dimensions,
                   String keepFormat,
                   String qualityStr,
                   boolean force)
            throws RepositoryException,
                   IOException
This method creates the web enabled rendition. if the force param is set to false than following check is executed: check if layer has to persisted. in case the layer is still equal than the ori file can be taken (save space).

Parameters:
image - buffered image used to create web enabled image
defaultMimetype - default output mimetype
dimensions - comma separated string containing max. with, max. height
keepFormat - contains all mimetypes that should be kept (instead of using the default mimetype)
qualityStr - image quality in percent
force - if true than the webenabled image is always created nevertheless the ori image is smaller than the requested image dimensions
Throws:
RepositoryException - in case the web rendition could not be persisted
IOException - while processing the image

saveImage

protected void saveImage(Asset asset,
                         Layer layer,
                         String mimetype,
                         double quality,
                         String renditionName)
                  throws IOException
Throws:
IOException

createImage

protected Layer createImage(BufferedImage image,
                            int maxWidth,
                            int maxHeight)
A image with the given maxWith and maxHeight is generated out if the image source.

Parameters:
image - image source
maxWidth - max. thumbnail width
maxHeight - max. thumbnail height
Returns:
the resized image layer

getExtension

protected String getExtension(String mimetype)

getMimeType

protected String getMimeType(Asset asset)

getDimension

protected Integer[] getDimension(String dimensions)

getQuality

protected double getQuality(double base,
                            String qualityStr)


Copyright © 2011-2013 Adobe Systems Incorporated. All Rights Reserved.