Use Aspect Crop to change the height or width of an image (either by cropping the image or expanding the area) to the 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 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 of 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 the area with the transparent pixels.
Width and Height settings
The values entered in the width and height fields are used to calculate the aspect ratio. Each value is thus one part of the ratio. The default width is 1 and the default height is 1. Transformed images cropped using the default settings are square.
These settings aren't used to specify the width and height of the transformed image.
There are many ways you can define an aspect ratio using the width and height.
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 and vertical offsets
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.
The Horizontal Offset and Vertical Offset settings both accept values between 0 and 1 and can include decimals.
Use the default values or enter both an Horizontal Offset and Vertical Offset so that you can apply this transformation to images of various aspect ratios. Aspect Crop only applies one of the positions to each image. The aspect ratio specified in the transformation and that of the original image determines which to use.
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.
When used with the horizontal offset, the allowExpansion setting defines the horizontal position of the image on the new expanded image canvas by specifying where to add the transparent pixels. Select 0 to position the fully transparent pixels to the right of the image, 1 to position the pixels to the left of the image, and .5 to horizontally center the image between the transparent pixels.
When used with the vertical offset, the allowExpansion 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.
If you add the IMQuery transformation to a policy, use the
imvariable, 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.
Updated over 1 year ago