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 library. In Brightspot, the implementation that is configured for use is exposed in the image editor UI.

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" override="false" />
 <Environment name="dari/imageEditor/dims/class" type="java.lang.String" value="com.psddev.dari.util.DimsImageEditor" override="false" />
 <Environment name="dari/imageEditor/dims/sharedSecret" type="java.lang.String" value="XCCC48" override="false" />
 <Environment name="dari/imageEditor/dims/useLegacyThumbnail" type="java.lang.String" value="false" override="false" />

In the previous snippet—

  • In line 2, the dari/defaultImageEditor name-value pair is set with the dims keyword, indicating that DimsImageEditor is the default editor implementation to use.
  • In the remaining lines, the keys are expressed with the dari/imageEditor/{implementation}/{option} pattern. The {implementation} placeholder is replaced with the dims keyword, indicating that the configuration option is associated with DimsImageEditor. The {option} placeholder is replaced with the name of the configuration parameter, which is set with the value attribute.
  • All name-value pairs include an override attribute that takes a true or false value. This attribute is relevant if the same option is set in the web application deployment descriptor. If it is set there, then the attribute determines whether that setting can override the value of the name-value pair in context.xml.

The options for image editor configuration are described below.


The following named values apply to both the Dims and Java image editors.

Key: dari/defaultImageEditor Type: java.lang.String

The name of the default image editor. For DimsImageEditor, set dims. For JavaImageEditor, set _java. For subsequent configuration options, replace the {implementation} placeholder with dims or _java.

If the editor is not specified in the URL, then Dari uses the value set for this key.

Key: dari/imageEditor/{implementation}/class Type: java.lang.String
The fully qualified class name of a com.psddev.dari.util.ImageEditor implementation.
Key: dari/imageEditor/{implementation}/crop Type: java.lang.String
The cropping option. Available settings are none, automatic, circle, star, and starburst. The default is automatic.
Key: dari/imageEditor/{implementation}/resize Type: java.lang.String
The resize option. Available settings are ignoreAspectRatio, onlyShrinkLarger, onlyEnlargeSmaller, and fillArea. The default is to do nothing.
Key: dari/imageEditor/{implementation}/baseUrl Type: java.lang.String
Base URL to the image editor implementation. For JavaImageEditor, if no baseUrl is set, Dari uses the baseUrl from the request. For DimsImageEditor, if no baseUrl is set, Dari falls back to first item from the baseUrls setting.
Key: dari/imageEditor/{implementation}/privateBaseUrl Type: java.lang.String
Setting key for the private base URL for the image editor implementation. If this URL is set, it will be used as the base URL.

DIMS Image Editor

The following named values are specific to DimsImageEditor.

Key: dari/imageEditor/dims/baseUrls Type: java.lang.String
Optional subsetting of baseUrl, which is used to construct the base URL of the DIMS URL. 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.
Key: dari/imageEditor/dims/sharedSecret Type: java.lang.String
The shared secret to use when signing URLs. The default is to not use a shared secret.
Key: dari/imageEditor/dims/expireTimestamp Type: java.util.Date
The 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.
Key: dari/imageEditor/dims/expireDuration Type: Long
The expiration duration in seconds of a signed URL. Set either this key or expireTimestamp, but not both.
Key: dari/imageEditor/dims/quality Type: java.lang.Integer
Quality in percentage for the output image (do not include percent sign). By default, quality is 100%.
Key: dari/imageEditor/dims/useLegacyCrop Type: boolean

Enables the use of DIMS’ legacy crop command. If false (the default), all crops are done automatically, regardless of the crop dimensions provided (x, y, width, height). Resize and crop are done in a single operation.

If true, backward compatibility behavior is enforced. That is, if there are crop dimensions (x, y, width, height) defined, then a normal (non-auto) crop takes place. If however, only the width and height are present, then an automatic crop occurs.

Key: dari/imageEditor/dims/useLegacyThumbnail Type: boolean
Enables the use of DIMS’ legacy thumbnail command. The command behavior is synonymous with the DIMS crop command. The default is false.
Key: dari/imageEditor/dims/preserveMetadata Type: boolean
Enables the preservation of the image’s metadata. The default is true.
Key: dari/imageEditor/dims/appendImageUrls Type: boolean

Enables appending image URLs instead of passing them as a parameter.

If false (the default), Dari constructs the DIMS’ URL to pass the image URL as a parameter (includes ?url parameter), for example:

If true, Dari constructs the DIMS URL to append the image URL (excludes ?url parameter), for example:

You can control some of the parameters passed to DIMS at runtime. For details, see Image Format and Runtime Image Quality and Compression.

See also:

Image URLs