Multi-crop: under the hood

Build 1501 on 14/Nov/2017  This topic last edited on: 5/Aug/2014, at 13:03

The Multi-crop activity allows to set the crop parameters (vertexes, rotation, etc...) of many images at time, according to the input variantTypes.

This is used, for example, to prepare the article's variant images before the web publishing.

The MultiCrop activity receives as input parameters a list of image ids (ImageIds) and a list of variantsTypes (VariantTypeIds or VariantTYpeNames).

It receives a target folderObject too (ObjectIds), which is the object where the cropped variants will be stored by the workflow.

For example, the ObjectIds parameter contains the id of the article to be published on web.

The crop control is the same than the one displayed by the Crop activity (single cropping), but the data fields are collapsed by default to save space into the dialog.

When exiting, the MultiCrop interaction returns a xml with the crop data, which is then processed by the workflow.

Actually, the MultiCrop activity does not crop the image; it simply set the cropping values, such as RotateDegrees, etc..., that are then passed to the TransformData activity to perform the cropping operation.

Here is a syntax sample of the xml returned by the MultiCrop activity containing all the data of the image croppping to do:

<ArrayOfVariantTypeData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <VariantTypeData>

    <Id>5488</Id>

    <Name>Crop 200x400</Name>

    <Height>400</Height>

    <Width>200</Width>

    <ImageId>5083</ImageId>

    <Rotation>0</Rotation>

    <Flip>false</Flip>

    <Scale>-426</Scale>

    <x1>54</x1>

    <y1>0</y1>

    <x2>101</x2>

    <y2>94</y2>

    <VertexesString>54;0;101;94;</VertexesString>

  </VariantTypeData>

  <VariantTypeData>

    <Id>5489</Id>

    <Name>Crop 120x180</Name>

    <Height>180</Height>

    <Width>120</Width>

    <ImageId>5080</ImageId>

    <Rotation>0</Rotation>

    <Flip>false</Flip>

    <Scale>-100</Scale>

    <x1>310</x1>

    <y1>157</y1>

    <x2>430</x2>

    <y2>337</y2>

    <VertexesString>310;157;430;337;</VertexesString>

  </VariantTypeData>

</ArrayOfVariantTypeData>

The workflow can read the cropping data from this xml (using a TransformXml activity) and pass them to the TransformData activity to actually perform the crop.

See the wf_ArticleMultiCrop.xml workfow as example.

Here is a syntax sample of the MultiCrop activity:

<!-- set the crop frame of the input images -->

<MultiCrop

  x:Name="multiCrop"

  Title='my title'

  ObjectIds="{wf:ActivityBind mainWorkflow, Path=ObjectIds}"

  ImageIds='{wf:ActivityBind mainWorkflow, Path=...}'

  VariantTypeIds='{wf:ActivityBind mainWorkflow, Path=...}'

  AttributeName='preview'

  ThumbnailAttributeName='thumbnail'>

where the AttributeName is the name of the data-content attribute which contains the image to show into the main crop control at the center of the dialog (the default is 'data'). The ThumbnailAttributeName is the name of the data-content attribute which contains the little images to show into the images and variants list at the side of the dialog (the default is 'thumbnail').

See also

Configuring multicrop