You can round the corners of a rectangle image stored in Object Storage Service (OSS) by using the rounded-corners operation. This topic describes the parameter of the rounded-corners operation and provides examples on how to round the corners of a rectangle image.
Parameters
Operation name: rounded-corners
The following table describes the parameter that you can configure.
Parameter | Description | Value range |
---|---|---|
r | The radius of the corners. | [1,4096] |
Usage notes
- If the final format (PNG, WebP, or BMP) of an image supports alpha channels, the areas of the image outside the rounded rectangle become transparent. If the final format of the image is JPG, the areas of the image outside the rounded rectangle become white. We recommend that you save the processed image in the PNG format.
- If the specified radius for the rounded corners is greater than the radius of the largest incircle of the source image, the radius of the largest incircle of the source image is used as the radius to round the corners. In this case, the radius of the corners is equal to half of the shortest edge of the source image.
- The rounded-corners operation is not supported for GIF images.
Examples
You can use object URLs, OSS SDKs, or API operations to configure IMG parameters that are used to process images. In this example, object URLs are used. You can use object URLs to configure IMG parameters only for public-read images. If you want to configure IMG parameters for private images, use OSS SDKs or API operations. For more information, see IMG implementation modes.
This topic provides examples on how to round the corners of an image in the oss-console-img-demo-cn-hangzhou bucket in the China (Hangzhou) region. The image is hosted at the following URL:
- Round the corners of the source image.Configure the parameters based on the following requirements:
- Set the radius at which the corners are rounded to 30 pixels:
rounded-corners,r_30
. - Save the processed image in the JPG format:
format,jpg
. If the format of the source image is JPG, you can leave this parameter unspecified.
The URL used to apply the preceding parameters is https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/rounded-corners,r_30. - Set the radius at which the corners are rounded to 30 pixels:
- Crop the source image, round the corners of the cropped image, and save the processed image in the PNG format.Configure the parameters based on the following requirements:
- Crop the source image to 100 × 100 pixels from the default start position:
crop,w_100,h_100
. - Set the radius at which the corners are rounded to 10 pixels:
rounded-corners,r_10
. - Save the processed image in the PNG format:
format,png
.
The URL used to apply the preceding parameters is https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/crop,w_100,h_100/rounded-corners,r_10/format,png. - Crop the source image to 100 × 100 pixels from the default start position: