Support and Documentation

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

1

Sets the default image editor to the one identified as dims.

2

Specifies the class for the DIMS image editor.

3

Sets the configuration key sharedSecret to XCCC48.

4

Sets the configuration key useLegacyThumbnail to false.

The following sections describe the options for image editor configuration.

General image editor configuration

The following table lists available context.xml default configuration values for an image editor.

Table 30. 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 Configuring a 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.



Configuring a DIMS image editor

The following table lists available context.xml default configuration values for a DIMS image editor.

Table 31. 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:

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: