With this transformation, you can create arbitrary image crops with a fixed aspect ratio as a variant of the source image. 


Introduction

With this function, it is possible to create image predefined crops as a separate version without a graphics program or the censhare image editor. The frame size and the aspect ratio of the crop are defined in Master data/Image crops. Users can select the desired cropping in the dialog.

The transformation is triggered with the  Asset > Variants > Create transformation variant action.

Example

In the Create transformation variant dialog, you can select the desired aspect ratio and area:

Configuration

To configure the action and the dialog, the following module assets are required in your system:

  • XSLT: Variant Picture Crop

    • Picture Crop Dialog
    • Picture Crip Dialog (censhare 5 Web)
  • XSLT: Localization

These assets are part of the censhare standard product.

Predefined image crops

In the censhare Admin Client, do the following:

  1. Go to Master data/Image crops and open the configuration.
  2. To add a new image cropping, click , select an ID and Name, and enter the desired settings:

    FieldDescription
    Fixed aspect ratioEnter a width x height ratio of the target image. The actual size in pixels is variable, unless you select Fixed size.
    Fixed sizeSelect to define an absolute height or width or both of the target image.
    Fixed widthEnter a value in pixels. You can enter only one value and leave the other empty.
    Fixed height
  3. To edit a default cropping, first, enable the admin mode, and then double-click the desired entry and edit it as desired.
  4. Click OK to save your changes.

Enable manual server action

The manual server action allows users to perform the cropping manually. 

In the censhare Admin Client, do the following:

  1. Go to Configuration/Modules/Transformations/Transformation variants and open Create image transformation variant.
  2. For the General setup, see Server actions.

  3. In the Special setup area, configure the following:
    • Under Transformation asset, select the transformation to be used. The default XSLT: Variant Picture Crop is preselected.

      If you use custom transformations, make sure that image metadata is copied to the variants. In the XSLT: Variant Picture Crop transformation, this is enabled by default. For more information, see Metadata handling in variants and dynamic downloads.

    • Under Name (Xpath expression), enter an XPath expression to build the variant name. Default is concat(@name, ' (', $image-variant/@key, ' Variant)'). This combines the original asset name, the transformation variant, and the suffix "variant".
    • In the Image crop field, click  to add an image ratio from the Master data/Image crops table that users can select in the dialog.
  4. Click OK to save your changes.
  5. Update the server configuration and - if necessary - synchronize the remote servers.

Enable automatic server action

The automatic server action executes the cropping automatically. The action is triggered by a defined event, for example: a new image is uploaded. 

In the censhare Admin Client, do the following:

  1. Go to Configuration/Modules/Transformations/Transformation variants and open Create image transformation variant (automatic).
  2. For the General setup and the Trigger events configuration, see Configure automatic server actions.
  3. For the Special setup, see Enable manual server action above.
  4. Click OK to save your changes.
  5. Update the server configuration and, if necessary, synchronize the remote servers.

Next steps

Make sure that in the Configuration/Modules/Transformations/Transformation variants/Synchronize transformation variants (automatic), is enabled and properly configured. This action updates the variant automatically when a new version of the source asset is created.

Optionally, enable as well the manual action Update transformation variant. With this action, users can update the variant manually.