Content Delivery Network

Image trimming

2024-05-31 07:31:15

After enabling image processing, customers can crop specific content from the original image and generate a new image by including cropping parameters in the request URL.

Note:
Image processing is a paid service. Currently, it is in a public beta phase and there are no charges. The timing for when fees will be introduced will be announced separately.

Centered Cropping: Crops an image of the specified width and height from the centered portion of the image. The starting point for width is (total image width - w) / 2, and the starting point for height is (total image height - h) / 2. The image content of width × height is then cropped from this origin point.

Specified X, Y Axis Cropping: Crops an image of the specified width and height based on the given x, y coordinates. The cropping starts from the point (x, y) and proceeds for the specified width and height.

Grid Cropping: Sets the origin position based on a 3x3 grid. The image is cropped horizontally by the indicated width (w) to the right and vertically by the indicated height (h) downward, starting from the set origin point.

Parameter Description and Examples
Parameter Name: cut.

Supported Parameter Value Descriptions:

Parameter TypeParametersDescriptionValue Range
Trimming typemidCentered cropping parameter, used with parameters w and h.N/A
xSpecified X, Y axis cropping parameter, indicating the horizontal starting point for cropping. Used with parameters y, w, h, and is required.Cannot exceed the original image width. If x exceeds the width, the original image will be returned.
ySpecified X, Y axis cropping parameter, indicating the vertical starting point for cropping. Used with parameters x, w, h, and is required.Cannot exceed the original image height. If y exceeds the height, the original image will be returned.
gGrid cropping parameter, sets the origin position for cropping. The origin is positioned in a 3x3 grid with nine positions.

NW: Top Left,

N: Top Center, 

NE: Top Right, 

W: Middle Left, 

M: Center, 

E: Middle Right, 

SW: Bottom Left, 

S: Bottom Center, 

SE: Bottom Right. 

Values outside this range will not trigger cropping and the original image will be returned.

Trimming width and heightwSpecifies the width of the crop from the origin point to the right. Used with centered cropping, specified X, Y axis cropping, and grid cropping parameters.Cannot exceed the original image width. If w exceeds the width, it will be cropped to the corresponding maximum width.
hSpecifies the height of the crop from the origin point downward. Used with centered cropping, specified X, Y axis cropping, and grid cropping parameters.Cannot exceed the original image height. If h exceeds the height, it will be cropped to the corresponding maximum height.


Operation Instructions and Examples:

Trimming TypeDescriptionsExamples
Centered trimming

The parameters are mid, w, h. It crops the specified width and height content from the center of the image. The starting point of width is (total width of image - w)/2, and the starting point of height is (total height of image - h)/2. After finding this origin point, it crops the image content with a size of width (w) × height (h). 

http://www.example.com/a.png?action=cut:mid,w_400,h_200.

Crops the specified width and height content from the center of the image. The starting point of width is (total width of image - w)/2, and the starting point of height is (total height of image - h)/2. Then, it crops the image content with a size of 400×200 starting from that origin point.

Specified X, Y Axis trimmingThe parameters are x, y, w, h. It crops the specified width and height content based on the given x, y, width (w), and height (h). Taking x and y as the starting point, it crops the image content with a size of width (w) × height (h). Note: The x, y values must be filled in, or else the original image will be returned. 

http://www.example.com/a.png?action=cut:x_10,y_10,w_400,h_200.

Crops by the specified origin point of x=10, y=10, and crops the image content with a size of 400×200 starting from that point.

Grid trimmingThe parameters are g, w, h. It sets the origin point based on a 3x3 grid layout. The horizontal crop direction is to the right with the indicated width (w), and the vertical crop direction is downward with the indicated height (h). It crops the image content with a specified width and height.

 http://www.example.com/a.png?action=cut:g_NW,w_400,h_200.

Grid Crop: Sets the origin point to the upper left corner of the 3x3 grid. It crops the image content with a width of 400 indicated by w to the right, and a height of 200 indicated by h downward, resulting in a cropped image content of 400×200.


LFtrwn24xZvH