This API is used to perform cropping, including regular cropping, scaling and cropping, inscribed circle cropping, rounded corner cropping, and smart cropping in Tencent Cloud CI.
download_url?imageMogr2/cut/<width>x<height>x<dx>x<dy>
/crop/<imageSizeAndOffsetGeometry>
/iradius/<radius>
/rradius/<radius>
/scrop/<Width>x<Height>
Ignore the preceding spaces and line breaks.
Parameter | Description |
---|---|
download_url | URL that is used to access a file. The URL form is <BucketName-APPID>.cos.<picture region>.<domain>.com/<picture name> , for example, examplebucket-1250000000.cos.ap-shanghai.myqcloud.com/picture.jpeg . |
Operation name: cut.
Parameter | Description |
---|---|
<width> | Specifies the width of the target image to Width. |
<height> | Specifies the height of the target image to Height. |
<dx> | Horizontally moves rightward relative to the upper-left vertex of the image by dx. |
<dy> | Downward offset by dy relative to the upper-left vertex of the image |
The value range is greater than 0 and smaller than the width and height of the original image.
Operation name: crop.
Parameter | Description |
---|---|
/crop/<Width>x | Specifies the width of the target image to Width while keeping the height unchanged. The value range of Width is greater than 0 and smaller than the width of the original image. |
/crop/x<Height> | Specifies the height of the target image to Height while keeping the width unchanged. The value range of Height is greater than 0 and smaller than the Height of the original image. |
/crop/<Width>x<Height> | Specifies the target Width and Height for an image. Both Width and Height should have a value above 0 and below the original value. |
When performing scaling and cropping, you can also use the gravity parameter to specify the start position of the operation. For more information, see [Example of scaling and cropping](#Scaling and cropping).
Operation name: iradius.
Parameter | Description |
---|---|
/iradius/<radius> | Inscribed circle cropping. radius indicates the radius of the inscribed circle. The value is an integer that is greater than 0 and smaller than half of the smallest edge of the original image. The center of the inscribed circle is the center of the image. This parameter is not supported when the image format is gif. |
Operation name: rradius.
Parameter | Description |
---|---|
/rradius/<radius> | Rounded corner cropping. radius indicates the rounded corner edge radius of the image. The value is an integer that is greater than 0 and smaller than half of the smallest edge of the original image. The rounded corner is tangent to the edge of the original image. This parameter is not supported when the image format is gif. |
Operation name: scrop.
Parameter | Description |
---|---|
/scrop/<Width>x<Height> | Scales and crops an image based on the face position in the image. The width and height of the target image are Width and Height. |
A 3x3 grid position diagram provides position reference for multiple image operations. Red dots show the origin points of each region. After you use the gravity parameter to select a region, displacement must be based on the corresponding origin point.
This example shows you how to horizontally move rightward by 100 pixels and vertically move downward by 10 pixels relative to the upper-left vertex of the image and specify the size of the target image as 600x600 for cropping.
http://examples-1251000004.cos.ap-shanghai.myqcloud.com/sample.jpeg?imageMogr2/cut/600x600x100x10
The original image is as follows:
The final effect is as follows:
This example shows you how to scale and crop an image to 300x400 by using the center as the reference point.
http://examples-1251000004.cos.ap-shanghai.myqcloud.com/sample.jpeg?imageMogr2/crop/300x400/gravity/center
The final effect is as follows:
This example shows you how to perform inscribed circle cropping when the radius is 200.
http://examples-1251000004.cos.ap-shanghai.myqcloud.com/sample.jpeg?imageMogr2/iradius/200
The final effect is as follows:
This example shows you how to perform rounded corner cropping when the radius is 100.
http://examples-1251000004.cos.ap-shanghai.myqcloud.com/sample.jpeg?imageMogr2/rradius/100
The final effect is as follows:
This example shows you how to scale and crop an image to 100x600 based on the position of the face in the image.
http://examples-1251000004.cos.ap-shanghai.myqcloud.com/sample.jpeg?imageMogr2/scrop/100x600
If no face is recognized in the image, the original image is returned.
Was this page helpful?