Package org.nuxeo.ecm.platform.picture
Class ImagingComponent
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.platform.picture.ImagingComponent
-
- All Implemented Interfaces:
ImagingService,Adaptable,Component,Extensible,TimestampedService
public class ImagingComponent extends DefaultComponent implements ImagingService
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIGURATION_PARAMETERS_EPprotected Map<String,String>configurationParametersstatic StringPICTURE_CONVERSIONS_EPprotected PictureConversionRegistrypictureConversionRegistry-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description ImagingComponent()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected BlobcallPictureConversionChain(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, Point size, String conversionFormat)protected booleancanApplyPictureConversion(PictureConversion pictureConversion, DocumentModel doc)protected PictureViewcomputeView(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)protected PictureViewcomputeView(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo)protected PictureViewcomputeView(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)PictureViewcomputeViewFor(Blob blob, PictureConversion pictureConversion, boolean convert)PictureViewcomputeViewFor(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)List<List<PictureView>>computeViewsFor(List<Blob> blobs, List<PictureConversion> pictureConversions, boolean convert)List<List<PictureView>>computeViewsFor(List<Blob> blobs, List<PictureConversion> pictureConversions, ImageInfo imageInfo, boolean convert)List<PictureView>computeViewsFor(Blob blob, List<PictureConversion> pictureConversions, boolean convert)List<PictureView>computeViewsFor(Blob blob, List<PictureConversion> pictureConversions, ImageInfo imageInfo, boolean convert)List<PictureView>computeViewsFor(DocumentModel doc, Blob blob, ImageInfo imageInfo, boolean convert)Compute all the registeredPictureConversionFor each picture template theImagingService.computeViewFor(Blob, PictureConversion, ImageInfo, boolean)method is callprotected PictureViewcomputeViewWithoutConversion(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo)BlobconvertToPDF(Blob blob)Converts an image to PDF.protected ActionContextcreateActionContext(DocumentModel doc)Blobcrop(Blob blob, int x, int y, int width, int height)Crops an image.StringgetConfigurationValue(String configurationName)Returns the value a configuration which name is received as parameter.StringgetConfigurationValue(String configurationName, String defaultValue)Returns the value a configuration which name is received as parameter.ImageInfogetImageInfo(Blob blob)Map<String,Object>getImageMetadata(Blob blob)Retrieves metadata from an image contained in aBlob.StringgetImageMimeType(File file)Returns the mime-type for the given file.StringgetImageMimeType(Blob blob)Returns the mime-type for the given BlobPictureConversiongetPictureConversion(String id)Returns aPictureConversiongiven itsid.List<PictureConversion>getPictureConversions()Returns the registered picture conversions.protected static PointgetSize(Point current, int max)Deprecated.since 11.1 useImageResizer.scaleToMax(int, int, int)instead.voidregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)Blobresize(Blob blob, String finalFormat, int width, int height, int depth)Resizes image.Blobrotate(Blob blob, int angle)Rotates an image.voidsetConfigurationValue(String configurationName, String configurationValue)Sets the value of a configuration which could be used by the ImagingService.voidunregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)protected BlobwrapBlob(Blob blob)-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
CONFIGURATION_PARAMETERS_EP
public static final String CONFIGURATION_PARAMETERS_EP
- See Also:
- Constant Field Values
-
PICTURE_CONVERSIONS_EP
public static final String PICTURE_CONVERSIONS_EP
- See Also:
- Constant Field Values
-
pictureConversionRegistry
protected PictureConversionRegistry pictureConversionRegistry
-
-
Method Detail
-
getPictureConversions
public List<PictureConversion> getPictureConversions()
Description copied from interface:ImagingServiceReturns the registered picture conversions.- Specified by:
getPictureConversionsin interfaceImagingService
-
getPictureConversion
public PictureConversion getPictureConversion(String id)
Description copied from interface:ImagingServiceReturns aPictureConversiongiven itsid.- Specified by:
getPictureConversionin interfaceImagingService
-
crop
public Blob crop(Blob blob, int x, int y, int width, int height)
Description copied from interface:ImagingServiceCrops an image.- Specified by:
cropin interfaceImagingService
-
resize
public Blob resize(Blob blob, String finalFormat, int width, int height, int depth)
Description copied from interface:ImagingServiceResizes image.- Specified by:
resizein interfaceImagingService
-
rotate
public Blob rotate(Blob blob, int angle)
Description copied from interface:ImagingServiceRotates an image.- Specified by:
rotatein interfaceImagingService- Parameters:
blob- a Blob containing the imageangle- the angle of the rotation- Returns:
- a Blob holding the rotated image
-
convertToPDF
public Blob convertToPDF(Blob blob)
Description copied from interface:ImagingServiceConverts an image to PDF.- Specified by:
convertToPDFin interfaceImagingService- Parameters:
blob- a Blob containing the image- Returns:
- a Blob holding the resulting PDF
-
getImageMetadata
public Map<String,Object> getImageMetadata(Blob blob)
Description copied from interface:ImagingServiceRetrieves metadata from an image contained in aBlob.- Specified by:
getImageMetadatain interfaceImagingService- Returns:
- the image metadata as a map String -> Object
-
getImageMimeType
public String getImageMimeType(File file)
Description copied from interface:ImagingServiceReturns the mime-type for the given file.- Specified by:
getImageMimeTypein interfaceImagingService
-
getImageMimeType
public String getImageMimeType(Blob blob)
Description copied from interface:ImagingServiceReturns the mime-type for the given Blob- Specified by:
getImageMimeTypein interfaceImagingService
-
getImageInfo
public ImageInfo getImageInfo(Blob blob)
Description copied from interface:ImagingServiceRetrieves theImageInfoof theBlobthat is received as parameter.The information provided by the ImageInfo, like width, height or format, is obtained using ImageMagick (see http://www.imagemagick.org/script/index.php for more details on ImageMagick).
- Specified by:
getImageInfoin interfaceImagingService- Parameters:
blob- the blob of a picture- Returns:
- the
ImageInfoof a blob
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContributionin classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContributionin classDefaultComponent
-
getConfigurationValue
public String getConfigurationValue(String configurationName)
Description copied from interface:ImagingServiceReturns the value a configuration which name is received as parameter.- Specified by:
getConfigurationValuein interfaceImagingService- Parameters:
configurationName- the name of the configuration- Returns:
- the value of the configuration, which can be null in case no configuration with the specified name was registered
-
getConfigurationValue
public String getConfigurationValue(String configurationName, String defaultValue)
Description copied from interface:ImagingServiceReturns the value a configuration which name is received as parameter. In case no configuration with the specified name was registered, the received defaultValue parameter will be returned.- Specified by:
getConfigurationValuein interfaceImagingService- Parameters:
configurationName- the name of the configurationdefaultValue- the value of the configuration
-
setConfigurationValue
public void setConfigurationValue(String configurationName, String configurationValue)
Description copied from interface:ImagingServiceSets the value of a configuration which could be used by the ImagingService.- Specified by:
setConfigurationValuein interfaceImagingService- Parameters:
configurationName- the name of the configurationconfigurationValue- the value of the configuration
-
computeViewFor
public PictureView computeViewFor(Blob blob, PictureConversion pictureConversion, boolean convert)
Description copied from interface:ImagingService- Specified by:
computeViewForin interfaceImagingServiceconvert- true if theblobis converted to fit thepictureConversion, false if theblobis put as it in the PictureView (without any conversion)- Returns:
- the computed picture view
-
computeViewFor
public PictureView computeViewFor(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)
Description copied from interface:ImagingService- Specified by:
computeViewForin interfaceImagingServiceimageInfo- theImageInfoto use when computing the viewconvert- true if theblobis converted to fit thepictureConversion, false if theblobis put as it in the PictureView (without any conversion)- Returns:
- the computed picture view
-
computeViewsFor
public List<PictureView> computeViewsFor(Blob blob, List<PictureConversion> pictureConversions, boolean convert)
Description copied from interface:ImagingService- Specified by:
computeViewsForin interfaceImagingServiceconvert- true if theblobis converted to fit eachPictureConversion, false if theblobis put as it in the PictureView (without any conversion)- Returns:
- the computed picture views as a List of
PictureViews
-
computeViewsFor
public List<PictureView> computeViewsFor(Blob blob, List<PictureConversion> pictureConversions, ImageInfo imageInfo, boolean convert)
Description copied from interface:ImagingService- Specified by:
computeViewsForin interfaceImagingServiceimageInfo- theImageInfoto use when computing the viewconvert- true if theblobis converted to fit eachPictureConversion, false if theblobis put as it in the PictureView (without any conversion)- Returns:
- the computed picture views as a List of
PictureViews
-
computeView
protected PictureView computeView(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)
-
computeView
protected PictureView computeView(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)
-
computeView
protected PictureView computeView(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo)
-
callPictureConversionChain
protected Blob callPictureConversionChain(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, Point size, String conversionFormat)
-
computeViewsFor
public List<PictureView> computeViewsFor(DocumentModel doc, Blob blob, ImageInfo imageInfo, boolean convert)
Description copied from interface:ImagingServiceCompute all the registeredPictureConversionFor each picture template theImagingService.computeViewFor(Blob, PictureConversion, ImageInfo, boolean)method is call- Specified by:
computeViewsForin interfaceImagingService
-
canApplyPictureConversion
protected boolean canApplyPictureConversion(PictureConversion pictureConversion, DocumentModel doc)
-
createActionContext
protected ActionContext createActionContext(DocumentModel doc)
-
computeViewWithoutConversion
protected PictureView computeViewWithoutConversion(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo)
-
getSize
@Deprecated protected static Point getSize(Point current, int max)
Deprecated.since 11.1 useImageResizer.scaleToMax(int, int, int)instead.
-
computeViewsFor
public List<List<PictureView>> computeViewsFor(List<Blob> blobs, List<PictureConversion> pictureConversions, boolean convert)
Description copied from interface:ImagingService- Specified by:
computeViewsForin interfaceImagingServiceconvert- true if theblobis converted to fit eachPictureConversion, false if theblobis put as it in the PictureView (without any conversion)
-
computeViewsFor
public List<List<PictureView>> computeViewsFor(List<Blob> blobs, List<PictureConversion> pictureConversions, ImageInfo imageInfo, boolean convert)
Description copied from interface:ImagingService- Specified by:
computeViewsForin interfaceImagingServiceimageInfo- theImageInfoto use when computing the viewconvert- true if theblobis converted to fit eachPictureConversion, false if theblobis put as it in the PictureView (without any conversion)
-
-