Updated on 2024-02-29 GMT+08:00

Indexcropping

You can edit code on OBS Console or make an API call to crop images based on indexes.

Set the top left corner of the image as the starting point. Set x-axis overlapping with the width, and y-axis overlapping with the height. Crop the image into several consecutive partitions horizontally or vertically, each having equal width or height. Get the partition you want according to the index. For details, see Table 1.

Operation name: indexcrop

Table 1 Indexcrop description

Parameter

Value Description

Code Example

x

Width of each partition after horizontal cropping, ranging [1, original width of the image]. x and y cannot be chosen at the same time.

image/indexcrop,x_1000,i_0

y

Height of each partition after vertical cropping, ranging [1, original height of the image].

x and y cannot be chosen at the same time.

i

If there are n partitions in total, i ranges [0, n-1]. When i = 0, you obtain the first partition. If you set a value larger than n-1, the original image will be returned.

Example

  • Indexcrop the image horizontally. The width of each partition is 1000. Choose the first partition.

    https://obs.region.example.com/image-demo/example.jpg?x-image-process=image/indexcrop,x_1000,i_0

  • Indexcrop the image horizontally. The width of each partition is 600. Choose the first partition.

    https://obs.region.example.com/image-demo/example.jpg?x-image-process=image/indexcrop,x_600,i_0