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 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" />
 <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" />

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.

General 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 DimsImageEditor, set to dims.
  • For JavaImageEditor, set to _java.

For subsequent configuration options, replace {implementation} with dims or _java. Clients can override this default value by specifying an image editor in the URL; for details, see Understanding Image URLs.

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.

  • 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 setting dari/imageEditor/dims/baseUrls (see table Configuration settings for DIMS image editor).
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.

DIMS Image Editor Configuration

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.

  • 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. 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.
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:

If dari/imageEditor/dims/appendImageUrls is 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.

See also: