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 String
CONFIGURATION_PARAMETERS_EP
protected Map<String,String>
configurationParameters
static String
PICTURE_CONVERSIONS_EP
protected PictureConversionRegistry
pictureConversionRegistry
-
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 Blob
callPictureConversionChain(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, Point size, String conversionFormat)
protected boolean
canApplyPictureConversion(PictureConversion pictureConversion, DocumentModel doc)
protected PictureView
computeView(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)
protected PictureView
computeView(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo)
protected PictureView
computeView(DocumentModel doc, Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo, boolean convert)
PictureView
computeViewFor(Blob blob, PictureConversion pictureConversion, boolean convert)
PictureView
computeViewFor(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 registeredPictureConversion
For each picture template theImagingService.computeViewFor(Blob, PictureConversion, ImageInfo, boolean)
method is callprotected PictureView
computeViewWithoutConversion(Blob blob, PictureConversion pictureConversion, ImageInfo imageInfo)
Blob
convertToPDF(Blob blob)
Converts an image to PDF.protected ActionContext
createActionContext(DocumentModel doc)
Blob
crop(Blob blob, int x, int y, int width, int height)
Crops an image.String
getConfigurationValue(String configurationName)
Returns the value a configuration which name is received as parameter.String
getConfigurationValue(String configurationName, String defaultValue)
Returns the value a configuration which name is received as parameter.ImageInfo
getImageInfo(Blob blob)
Map<String,Object>
getImageMetadata(Blob blob)
Retrieves metadata from an image contained in aBlob
.String
getImageMimeType(File file)
Returns the mime-type for the given file.String
getImageMimeType(Blob blob)
Returns the mime-type for the given BlobPictureConversion
getPictureConversion(String id)
Returns aPictureConversion
given itsid
.List<PictureConversion>
getPictureConversions()
Returns the registered picture conversions.protected static Point
getSize(Point current, int max)
Deprecated.since 11.1 useImageResizer.scaleToMax(int, int, int)
instead.void
registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
Blob
resize(Blob blob, String finalFormat, int width, int height, int depth)
Resizes image.Blob
rotate(Blob blob, int angle)
Rotates an image.void
setConfigurationValue(String configurationName, String configurationValue)
Sets the value of a configuration which could be used by the ImagingService.void
unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
protected Blob
wrapBlob(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:ImagingService
Returns the registered picture conversions.- Specified by:
getPictureConversions
in interfaceImagingService
-
getPictureConversion
public PictureConversion getPictureConversion(String id)
Description copied from interface:ImagingService
Returns aPictureConversion
given itsid
.- Specified by:
getPictureConversion
in interfaceImagingService
-
crop
public Blob crop(Blob blob, int x, int y, int width, int height)
Description copied from interface:ImagingService
Crops an image.- Specified by:
crop
in interfaceImagingService
-
resize
public Blob resize(Blob blob, String finalFormat, int width, int height, int depth)
Description copied from interface:ImagingService
Resizes image.- Specified by:
resize
in interfaceImagingService
-
rotate
public Blob rotate(Blob blob, int angle)
Description copied from interface:ImagingService
Rotates an image.- Specified by:
rotate
in 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:ImagingService
Converts an image to PDF.- Specified by:
convertToPDF
in 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:ImagingService
Retrieves metadata from an image contained in aBlob
.- Specified by:
getImageMetadata
in interfaceImagingService
- Returns:
- the image metadata as a map String -> Object
-
getImageMimeType
public String getImageMimeType(File file)
Description copied from interface:ImagingService
Returns the mime-type for the given file.- Specified by:
getImageMimeType
in interfaceImagingService
-
getImageMimeType
public String getImageMimeType(Blob blob)
Description copied from interface:ImagingService
Returns the mime-type for the given Blob- Specified by:
getImageMimeType
in interfaceImagingService
-
getImageInfo
public ImageInfo getImageInfo(Blob blob)
Description copied from interface:ImagingService
Retrieves theImageInfo
of theBlob
that 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:
getImageInfo
in interfaceImagingService
- Parameters:
blob
- the blob of a picture- Returns:
- the
ImageInfo
of a blob
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContribution
in classDefaultComponent
-
getConfigurationValue
public String getConfigurationValue(String configurationName)
Description copied from interface:ImagingService
Returns the value a configuration which name is received as parameter.- Specified by:
getConfigurationValue
in 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:ImagingService
Returns 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:
getConfigurationValue
in 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:ImagingService
Sets the value of a configuration which could be used by the ImagingService.- Specified by:
setConfigurationValue
in 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:
computeViewFor
in interfaceImagingService
convert
- true if theblob
is converted to fit thepictureConversion
, false if theblob
is 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:
computeViewFor
in interfaceImagingService
imageInfo
- theImageInfo
to use when computing the viewconvert
- true if theblob
is converted to fit thepictureConversion
, false if theblob
is 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:
computeViewsFor
in interfaceImagingService
convert
- true if theblob
is converted to fit eachPictureConversion
, false if theblob
is put as it in the PictureView (without any conversion)- Returns:
- the computed picture views as a List of
PictureView
s
-
computeViewsFor
public List<PictureView> computeViewsFor(Blob blob, List<PictureConversion> pictureConversions, ImageInfo imageInfo, boolean convert)
Description copied from interface:ImagingService
- Specified by:
computeViewsFor
in interfaceImagingService
imageInfo
- theImageInfo
to use when computing the viewconvert
- true if theblob
is converted to fit eachPictureConversion
, false if theblob
is put as it in the PictureView (without any conversion)- Returns:
- the computed picture views as a List of
PictureView
s
-
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:ImagingService
Compute all the registeredPictureConversion
For each picture template theImagingService.computeViewFor(Blob, PictureConversion, ImageInfo, boolean)
method is call- Specified by:
computeViewsFor
in 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:
computeViewsFor
in interfaceImagingService
convert
- true if theblob
is converted to fit eachPictureConversion
, false if theblob
is 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:
computeViewsFor
in interfaceImagingService
imageInfo
- theImageInfo
to use when computing the viewconvert
- true if theblob
is converted to fit eachPictureConversion
, false if theblob
is put as it in the PictureView (without any conversion)
-
-