Aspect Crop lets you change the height or width of an image (either by cropping or expanding the area) to an aspect ratio of your choosing.
Crop images to achieve the specified aspect ratio
You can use the transformation settings to help define the portion of the original image you want to keep when cropping it to achieve a new aspect ratio. Transformed images always preserve one of the original image dimensions.Here's the original image we'll use for the examples:
By default, Aspect Crop crops to a square aspect ratio centered both vertically and horizontally.
In the example below we’ve positioned the cropping so the subject’s face remains visible.
Expand images to achieve the specified aspect ratio
If you want to expand an image when changing the height or width to a new aspect ratio, enable the allowExpansion setting. You can also define the placement of the original image on the new expanded image canvas. The expanded area on the image canvas is filled with fully transparent pixels.
In the example below we positioned the transparent pixels on the left side of the image. We added a gray background color to represent the transparent pixels.
Width and Height settings
- Enter a pixel width and height directly
into the width and height fields.
For example, to achieve an aspect ratio of 16:9 enter a width of 1280 and a height of 720.
- Enter a single number into the width or
height field to represent the ratio.
For example, enter 1.7778 into the width field and 1 in the height field to achieve an aspect ratio of 16:9.
Horizontal Offset and Vertical Offset settings
Horizontal Offset specifies the horizontal portion of the image you want to keep when cropping the image to achieve the aspect ratio. Select 0 to position the cropped area to the left, 1 to position the cropped area on the right side, and .5 to center the cropping area horizontally on the image.
Vertical Offset specifies the vertical portion of the image you want to keep when cropping the image to achieve the aspect ratio. Select 0 to position the cropped area at the top of the image, 1 to position the cropped area on the bottom, and .5 center the cropping area vertically on the image.
When using allowExpansion this setting defines the vertical position of the image on the new expanded image canvas. Select 1 to position the fully transparent pixels at the top of the image, 0 to position the pixels at the bottom, and .5 to vertically center the image between the transparent pixels.
Enable this setting to apply fully transparent pixels to an image instead of cropping it to achieve the requested aspect ratio. Any extra area added to the canvas is filled with fully transparent pixels.
Use the Horizontal Offset setting to define the horizontal position and the Vertical Offset setting to define the vertical position of the original image on the new expanded canvas.
If you add the IMQuery transformation to a policy, use the im variable, and select Aspect Crop, you can use a query string to change the height or width of an image to an aspect ratio of your choosing. See Syntax and Examples for the syntax for the query string parameter.