|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.loader.CmsDumpLoader
org.opencms.loader.CmsImageLoader
public class CmsImageLoader
Loader for images from the OpenCms VSF with integrated image scaling and processing capabilities.
To scale or process an image, the parameter
has to be appended to the image URI. The value for the parameter needs to be composed from the CmsImageScaler.PARAM_SCALE
SCALE_PARAM
options provided by the constants in the
class.CmsResourceTypeImage
For example, to scale an image to exact 800x600 pixel with center fitting and a background color of grey,
the following parameter String can be used: w:800,h:600,t:0,c:c0c0c0
.
Field Summary | |
---|---|
static java.lang.String |
CONFIGURATION_DOWNSCALE
The configuration parameter for the OpenCms XML configuration to set the image down scale operation. |
static java.lang.String |
CONFIGURATION_IMAGE_FOLDER
The configuration parameter for the OpenCms XML configuration to set the image cache repository. |
static java.lang.String |
CONFIGURATION_MAX_BLUR_SIZE
The configuration parameter for the OpenCms XML configuration to set the maximum image blur size. |
static java.lang.String |
CONFIGURATION_MAX_SCALE_SIZE
The configuration parameter for the OpenCms XML configuration to set the maximum image scale size. |
static java.lang.String |
CONFIGURATION_SCALING_ENABLED
The configuration parameter for the OpenCms XML configuration to enable the image scaling. |
static java.lang.String |
IMAGE_REPOSITORY_DEFAULT
Default name for the image cache repository. |
protected static org.apache.commons.logging.Log |
LOG
The log object for this class. |
protected static java.lang.String |
m_downScaleParams
The (optional) image down scale parameters for image write operations. |
protected static boolean |
m_enabled
Indicates if image scaling is active. |
protected java.lang.String |
m_imageRepositoryFolder
The name of the configured image cache repository. |
protected static int |
m_maxBlurSize
The maximum image size (width * height) to apply image blurring when down scaling (setting this to high may cause "out of memory" errors). |
protected int |
m_maxScaleSize
The maximum image size (width or height) to allow when up scaling an image using request parameters. |
protected static CmsVfsNameBasedDiskCache |
m_vfsDiskCache
The disk cache to use for saving scaled image versions. |
static java.lang.String |
PARAM_CLEAR_IMAGES_CACHE
Clear event parameter. |
static int |
RESOURCE_LOADER_ID_IMAGE_LOADER
The id of this loader. |
Fields inherited from class org.opencms.loader.CmsDumpLoader |
---|
RESOURCE_LOADER_ID |
Fields inherited from interface org.opencms.loader.I_CmsResourceLoader |
---|
PARAMETER_ELEMENT |
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler |
---|
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD |
Constructor Summary | |
---|---|
CmsImageLoader()
Creates a new image loader. |
Method Summary | |
---|---|
void |
addConfigurationParameter(java.lang.String paramName,
java.lang.String paramValue)
Adds a configuration parameter to this parameter configurable class instance. |
void |
cmsEvent(CmsEvent event)
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class. |
void |
destroy()
Destroy this ResourceLoder, this is a NOOP so far. |
java.util.Map |
getConfiguration()
Will always return null since this loader does not
need to be configured. |
static java.lang.String |
getDownScaleParams()
Returns the image down scale parameters, which is set with the CONFIGURATION_DOWNSCALE configuration option. |
static java.lang.String |
getImageRepositoryPath()
Returns the path of the image cache repository folder in the RFS, which is set with the CONFIGURATION_IMAGE_FOLDER configuration option. |
int |
getLoaderId()
Returns the id of the ResourceLoader. |
static int |
getMaxBlurSize()
The maximum blur size for image re-scale operations, which is set with the CONFIGURATION_MAX_BLUR_SIZE configuration option. |
protected CmsFile |
getScaledImage(CmsObject cms,
CmsResource resource,
CmsImageScaler scaler)
Returns a scaled version of the given OpenCms VFS image resource. |
void |
initConfiguration()
Initializes a configuration after all parameters have been added. |
static boolean |
isEnabled()
Returns true if the image scaling and processing capabilities for the
OpenCms VFS images have been enabled, false if not. |
void |
load(CmsObject cms,
CmsResource resource,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Basic top-page processing method for a I_CmsResourceLoader, this method is called if the page is called as a sub-element on a page not already loaded with a I_CmsResourceLoader. |
Methods inherited from class org.opencms.loader.CmsDumpLoader |
---|
canSendLastModifiedHeader, dump, export, getResourceLoaderInfo, isStaticExportEnabled, isStaticExportProcessable, isUsableForTemplates, isUsingUriWhenLoadingTemplate, service |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CONFIGURATION_DOWNSCALE
public static final java.lang.String CONFIGURATION_IMAGE_FOLDER
public static final java.lang.String CONFIGURATION_MAX_BLUR_SIZE
public static final java.lang.String CONFIGURATION_MAX_SCALE_SIZE
public static final java.lang.String CONFIGURATION_SCALING_ENABLED
public static final java.lang.String IMAGE_REPOSITORY_DEFAULT
public static final java.lang.String PARAM_CLEAR_IMAGES_CACHE
public static final int RESOURCE_LOADER_ID_IMAGE_LOADER
protected static final org.apache.commons.logging.Log LOG
protected static java.lang.String m_downScaleParams
protected static boolean m_enabled
protected static int m_maxBlurSize
protected static CmsVfsNameBasedDiskCache m_vfsDiskCache
protected java.lang.String m_imageRepositoryFolder
protected int m_maxScaleSize
Constructor Detail |
---|
public CmsImageLoader()
Method Detail |
---|
public static java.lang.String getDownScaleParams()
CONFIGURATION_DOWNSCALE
configuration option.
If no down scale parameters have been set in the configuration, this will return null
.
public static java.lang.String getImageRepositoryPath()
CONFIGURATION_IMAGE_FOLDER
configuration option.
public static int getMaxBlurSize()
CONFIGURATION_MAX_BLUR_SIZE
configuration option.The default is 2500 * 2500 pixel.
public static boolean isEnabled()
true
if the image scaling and processing capabilities for the
OpenCms VFS images have been enabled, false
if not.
Image scaling is enabled by setting the loader parameter image.scaling.enabled
to the value true
in the configuration file opencms-vfs.xml
.
Enabling image processing in OpenCms may require several additional configuration steps on the server running OpenCms, especially in UNIX systems. Here it is often required to have an X window server configured and accessible so that the required Java ImageIO operations work. Therefore the image scaling capabilities in OpenCms are disabled by default.
true
if the image scaling and processing capabilities for the
OpenCms VFS images have been enabledpublic void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
I_CmsConfigurationParameterHandler
addConfigurationParameter
in interface I_CmsConfigurationParameterHandler
addConfigurationParameter
in class CmsDumpLoader
paramName
- the name of the parameterparamValue
- the value for the parameterI_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)
public void cmsEvent(CmsEvent event)
I_CmsEventListener
cmsEvent
in interface I_CmsEventListener
event
- CmsEvent that has occurredI_CmsEventListener.cmsEvent(org.opencms.main.CmsEvent)
public void destroy()
CmsDumpLoader
destroy
in interface I_CmsResourceLoader
destroy
in class CmsDumpLoader
I_CmsResourceLoader.destroy()
public java.util.Map getConfiguration()
CmsDumpLoader
null
since this loader does not
need to be configured.
getConfiguration
in interface I_CmsConfigurationParameterHandler
getConfiguration
in class CmsDumpLoader
null
I_CmsConfigurationParameterHandler.getConfiguration()
public int getLoaderId()
I_CmsResourceLoader
getLoaderId
in interface I_CmsResourceLoader
getLoaderId
in class CmsDumpLoader
I_CmsResourceLoader.getLoaderId()
public void initConfiguration()
I_CmsConfigurationParameterHandler
initConfiguration
in interface I_CmsConfigurationParameterHandler
initConfiguration
in class CmsDumpLoader
I_CmsConfigurationParameterHandler.initConfiguration()
public void load(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws java.io.IOException, CmsException
I_CmsResourceLoader
load
in interface I_CmsResourceLoader
load
in class CmsDumpLoader
cms
- the initialized CmsObject which provides user permissionsresource
- the requested OpenCms VFS resourcereq
- the servlet requestres
- the servlet response
java.io.IOException
- might be thrown by the servlet environment
CmsException
- in case of errors accessing OpenCms functionsI_CmsResourceLoader.load(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
protected CmsFile getScaledImage(CmsObject cms, CmsResource resource, CmsImageScaler scaler) throws java.io.IOException, CmsException
All results are cached in disk. If the scaled version does not exist in the cache, it is created. Unscaled versions of the images are also stored in the cache.
cms
- the current users OpenCms contextresource
- the base VFS resource for the imagescaler
- the configured image scaler
java.io.IOException
- in case of errors accessing the disk based cache
CmsException
- in case of errors accessing the OpenCms VFS
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |