Image editor configuration
Dari provides two image editor classes for image resizing, both of which use a web service API over HTTP.
The production implementation, DimsImageEditor, is built on Apache DIMS (Dynamic Image Manipulation Service). The testing implementation, JavaImageEditor, uses the ImageIO library. In Brightspot, the implementation that is configured for use is exposed in the image editor (see the illustration "Image editing form").
As implementations of SettingsBackedObject, DimsImageEditor and JavaImageEditor can be initialized by values stored in a configuration file. The following example shows configuration of the DIMS image editor in a Tomcat context.xml
file:
<!-- DIMS -->
<Environment name="dari/defaultImageEditor" type="java.lang.String" value="dims" />
<Environment name="dari/imageEditor/dims/class" type="java.lang.String" value="com.psddev.dari.util.DimsImageEditor" />
<Environment name="dari/imageEditor/dims/sharedSecret" type="java.lang.String" value="XCCC48" />
<Environment name="dari/imageEditor/dims/useLegacyThumbnail" type="java.lang.String" value="false" />
-
Sets the default image editor to the one identified as
dims
. -
Specifies the class for the DIMS image editor.
-
Sets the configuration key
sharedSecret
toXCCC48
. -
Sets the configuration key
useLegacyThumbnail
tofalse
.
The following sections describe the options for image editor configuration.
The following table lists available context.xml
default configuration values for an image editor.
General configuration settings for image editor
Key | Type | Description |
---|---|---|
dari/defaultImageEditor | java.lang.String | Name of the default image editor.
For subsequent configuration options, replace |
dari/imageEditor/{implementation}/class | java.lang.String | Fully qualified class name of a com.psddev.dari.util.ImageEditor implementation. |
dari/imageEditor/{implementation}/crop | java.lang.String | Cropping option. Available settings are none , automatic , circle , star , and starburst . The default is automatic. |
dari/imageEditor/{implementation}/resize | java.lang.String | Resize option. Available settings are ignoreAspectRatio , onlyShrinkLarger , onlyEnlargeSmaller , and fillArea . The default is to do nothing. |
dari/imageEditor/{implementation}/baseUrl | java.lang.String | Base URL to the image editor implementation.
|
dari/imageEditor/{implementation}/privateBaseUrl | java.lang.String | Private base URL for the image editor implementation. If this URL is set, it will be used as the base URL. |
The following table lists available context.xml
default configuration values for a DIMS image editor.
Configuration settings for DIMS image editor
Key | Type | Description |
---|---|---|
dari/imageEditor/dims/baseUrls | java.lang.String | Optional subsetting of dari/imageEditor/dims/baseUrls that is used to construct the base URL of the DIMS URL (see table "General configuration settings for image editor"). If the image URL is already a DIMS URL, then the DIMS base URL matching the base URL of that image URL is used; otherwise, the image URL is hashed and the DIMS-based URL is picked from the list of base URLs that are set on this option. |
dari/imageEditor/dims/sharedSecret | java.lang.String | Shared secret to use when signing URLs. The default is to not use a shared secret. |
dari/imageEditor/dims/expireTimestamp | java.util.Date | Expiration date of a signed URL. Set either this key or expireDuration , but not both. If neither key is set, then there is no expiration time. |
dari/imageEditor/dims/expireDuration | java.lang.Long | Expiration duration in seconds of a signed URL. Set either this key or expireTimestamp , but not both. |
dari/imageEditor/dims/quality | java.lang.Integer | Quality in percentage for the output image (do not include percent sign). By default, quality is 100%. |
dari/imageEditor/dims/useLegacyCrop | boolean | Enables the use of DIMS’s legacy crop command.
|
dari/imageEditor/dims/useLegacyThumbnail | boolean | Enables the use of DIMS’s legacy thumbnail command. The command behavior is synonymous with the DIMS crop command. The default is false . |
dari/imageEditor/dims/preserveMetadata | boolean | Enables preservation of the image’s metadata. The default is true . |
dari/imageEditor/dims/appendImageUrls | boolean | Enables appending image URLs instead of passing them as a parameter. |
If dari/imageEditor/dims/appendImageUrls
is false
(the default), Dari constructs the DIMS URL to pass the image URL as a parameter (includes ?url
parameter), for example:
http://domain.com/dims4/default/4d5c026/2147483647/strip/true/crop/90x58+156+104/resize/85x55?url=http%3A%2F%2Fdomain%2Fid%2F%2Fbowtie.png
If dari/imageEditor/dims/appendImageUrls
is true
, Dari constructs the DIMS URL to append the image URL (excludes ?url
parameter), for example:
http://domain.com/dims4/default/4d5c026/2147483647/strip/true/crop/90x58+156+104/resize/85x55/http%3A%2F%2Fdomain%2Fid%2F%2Fbowtie.png
You can control some of the parameters passed to DIMS at runtime. For details, see Image format.
See also: