You can use custom crop parameters to crop a rectangular image based on a specified size from a source image stored in OSS. This topic describes the parameters and examples to crop an image based on a specified dimension.

Parameters

Operation name: crop

The following table lists the parameters.

Parameter Description Valid value
w The width of the cropped area. [0, image width].

Default value: the maximum value.

h The height of the cropped area. [0, image height].

Default value: the maximum value.

x The abscissa of the starting point. By default, the origin is located in the upper-left corner. [0, image bound]
y The ordinate of the starting point. By default, the origin is located in the upper-left corner. [0, image bound]
g The location of the origin for cropping. The origin is located in the upper-left corner of any of the nine-cell matrix.
  • nw
  • north
  • ne
  • west
  • center
  • east
  • sw
  • south
  • se
The following schematic view shows the available locations for the origin.

The following schematic view shows the available locations for the origin.

Usage notes

Before you crop an image, take note of the following items:

  • If the specified starting abscissa or ordinate values exceed those of the source image, the system returns BadRequest and the following error message: Advance cut's position is out of image.
  • If the width and height specified from the starting point exceed those of the source image, the source image is cropped to its boundaries.

Examples

The image-demo bucket that is located in the China (Hangzhou) region is used as an example. Public endpoint of the image: