Updated on 2024-08-09 GMT+08:00

Common Cropping

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

You can start at any point on an image and crop the image into a rectangle with specified width and height. Table 1 describes the parameters.

This operation is represented by crop.

Table 1 Common cropping parameters

Parameter

Value Description

Code Example

g

The location where cropping starts. g can be set to tl, top, tr, left, center, right, bl, bottom, or br. Figure 1 shows a 3x3 grid illustrating these values. Each value locates at the top left corner of the cell.

image/crop,x_10,y_10,w_200,h_200,g_br

h

Cropping height. Its value ranges from 0 to Original height.

w

Cropping width. Its value ranges from 0 to Original width.

x

x-coordinate of the start point. The top left corner is the default origin. The parameter value ranges from 0 to Original image width.

y

y-coordinate of the start point. The top left corner is the default origin. The parameter value ranges from 0 to Original image height.

Figure 1 shows the cropping origins.

Figure 1 3x3 grid of cropping origins
  • If x is larger than the origin width, or y is larger than the origin height, the cropping cannot be executed and a fault will be returned.
  • If h is larger than the origin height and w is larger than the original width, the image will be cropped to the boundaries.

Examples