You can use indexed slice parameters to slice a source image stored in OSS based on the specified size and retrieve the required image. This topic describes the parameters and examples to perform indexed slicing.

Parameter description

Operation name: indexcrop

The following table describes the parameters that are used in the indexcrop operation.

Parameter Description Value range
x The length of each image partition during horizontal slicing. Only one of the x and y parameters can be specified. [1, image width]
y The length of each image partition during vertical slicing. Only one of the x and y parameters can be specified. [1, image height]
i The image partition selected after slicing. [0, maximum number of partitions)

The default value is 0, which indicates the first partition. If you want to return the last partition, perform indexed slicing based on the image size and the value range of the parameter.

Usage notes

  • If the specified index exceeds the number of partitions, the source image is returned.
  • If both x and y are specified and their values are valid, the value of y takes effect.

Examples

You can process images by using object URLs, OSS SDKs, or API operations. In this example, object URLs are used. For more information about how to use OSS SDKs and API operations to process images, see IMG implementation modes.

In the following examples, an image in a bucket named oss-console-img-demo-cn-hangzhou in the China (Hangzhou) region is used as the source image. The image can be accessed over the Internet by using the following URL: