Image actions

Veva offers image manipulations through query-string parameters in the asset-image urls.

Build in actions

By default veva comes with 3 action types

  • Crop
  • Resize
  • Sharpen

Reizing

To resize an image there are a few options

  • action=width:(width)
    • Set the width and the height will be calculated from the aspect-ratio of the original image
  • action=height:(height)
    • Set the height and the width will be calculated from the aspect-ratio of the original image
  • action=fit:(width)x(height)
    • Resizes the image so it fits into the given dimensions.
    • Dimension will be equal to or less then given arguments
  • action=cover:(width)x(height)
    • Resizes the image so it covers into the given dimensions.
    • Dimension will be equal to or larger then given arguments

Croping

To crop an image add an action=crop:(width)x(height) parameter

Example

/library/sampleimages/landscape.png?action=crop:100x100

Sharpen

After resizing an image it is often good to apply a little sharpen, this will give the image the effect of more clarity.

To apply sharpening add on of the following

  • action=sharpen:light
  • action=sharpen:medium
  • action=sharpen:strong

ActionParsers

IActionParser are used to parse the query-sting  they return a list of IImageProcedureStepHandler.

The actions-middleware takes each action parameter and runs them through the registered parsers.

The acions are applied in the same sequence as in the querystring

For exmaple

/library/sampleimages/landscape.png?action=crop:100x100&action=width:200

will first crop to 100x100 pixels and the resize to 200 pixels

/library/sampleimages/landscape.png?action=width:200&action=crop:100x100

will first resize to 200 pixels and the crop to 100x100 resulting in a much different result.

public interface IActionParser
{
IEnumerable ParseActionString(string action);
}

public interface IImageProcedureStepHandler
{
bool PixelRatioSensitive();
void ApplyStep(ImageProcedureSubject subject);
}