All Products
Search
Document Center

Object Storage Service:Rounded rectangle

Last Updated:Mar 20, 2026

The rounded-corners operation rounds the corners of an image stored in OSS.

Parameters

Operation name: rounded-corners

ParameterDescriptionValue range
rCorner radius, in pixels1–4096

Usage notes

  • Output format determines background behavior: Formats that support alpha channels (PNG, WebP, BMP) render the area outside the rounded corners as transparent. JPG renders it as white. Save images in PNG format to get transparent corners.

  • Radius cap: If the specified radius exceeds the largest inscribed circle of the source image, OSS uses the inscribed circle radius instead — equal to half the shortest edge.

  • GIF not supported: The rounded-corners operation cannot be applied to GIF images.

Round the corners of a public-read or public-read-write image

Append the x-oss-process query parameter to the image URL.

The following examples use the source image:

https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg

Source image

Example 1: Round the corners with a 30-pixel radius

Parameters:

  • Corner radius: rounded-corners,r_30

  • Output format: format,jpg (omit if the source image is already JPG)

https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/rounded-corners,r_30
Rounded corners, r=30

Example 2: Crop, round corners, and save as PNG

Parameters:

  • Crop to 100×100 pixels from the default start position: crop,w_100,h_100

  • Corner radius: rounded-corners,r_10

  • Output format: format,png

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
Cropped image with rounded corners, PNG

Round the corners of a private image

Use an OSS SDK or the RESTful API to process private images.

Use OSS SDKs

All examples below apply image/rounded-corners,r_30 using the x-oss-process parameter and save the result to a local file.

For SDKs in other languages, see Overview.

Python

Requires OSS SDK for Python V2.18.4 or later.

# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider

# Read credentials from environment variables OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())
endpoint = 'https://oss-cn-hangzhou.aliyuncs.com'
region = 'cn-hangzhou'
bucket = oss2.Bucket(auth, endpoint, 'examplebucket', region=region)

key = 'example.jpg'
new_pic = 'D:\\dest.jpg'

# Apply rounded corners with a 30-pixel radius.
image = 'image/rounded-corners,r_30'
bucket.get_object_to_file(key, new_pic, process=image)

Java

Requires OSS SDK for Java V3.17.4 or later.

import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.GetObjectRequest;
import java.io.File;

public class Demo {
    public static void main(String[] args) throws Throwable {
        // Specify the endpoint for the region where your bucket is located.
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        String region = "cn-hangzhou";
        // Read credentials from environment variables OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET.
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        String bucketName = "examplebucket";
        String objectName = "example.jpg";
        // Local path to save the processed image.
        String pathName = "D:\\dest.jpg";

        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(credentialsProvider)
                .clientConfiguration(clientBuilderConfiguration)
                .region(region)
                .build();

        try {
            // Apply rounded corners with a 30-pixel radius.
            String image = "image/rounded-corners,r_30";
            GetObjectRequest request = new GetObjectRequest(bucketName, objectName);
            request.setProcess(image);
            ossClient.getObject(request, new File(pathName));
        } catch (OSSException oe) {
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

Go

Requires OSS SDK for Go V3.0.2 or later.

package main

import (
	"fmt"
	"os"

	"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

func HandleError(err error) {
	fmt.Println("Error:", err)
	os.Exit(-1)
}

func main() {
	// Read credentials from environment variables OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET.
	provider, err := oss.NewEnvironmentVariableCredentialsProvider()
	if err != nil {
		HandleError(err)
	}

	client, err := oss.New("https://oss-cn-hangzhou.aliyuncs.com", "", "",
		oss.SetCredentialsProvider(&provider),
		oss.AuthVersion(oss.AuthV4),
		oss.Region("cn-hangzhou"))
	if err != nil {
		HandleError(err)
	}

	bucket, err := client.Bucket("examplebucket")
	if err != nil {
		HandleError(err)
	}

	sourceImageName := "example.jpg"
	targetImageName := "D://dest.jpg"

	// Apply rounded corners with a 30-pixel radius.
	image := "image/rounded-corners,r_30"
	err = bucket.GetObjectToFile(sourceImageName, targetImageName, oss.Process(image))
	if err != nil {
		HandleError(err)
	}
}

PHP

Requires OSS SDK for PHP V2.7.0 or later.

<?php
if (is_file(__DIR__ . '/../autoload.php')) {
    require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
    require_once __DIR__ . '/../vendor/autoload.php';
}
use OSS\Credentials\EnvironmentVariableCredentialsProvider;
use OSS\OssClient;

// Read credentials from environment variables OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET.
$provider = new EnvironmentVariableCredentialsProvider();
$endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
$bucket = "examplebucket";
$object = "example.jpg";
$download_file = "D:\\dest.jpg";

$config = array(
    "provider" => $provider,
    "endpoint" => $endpoint,
    "signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
    "region" => "cn-hangzhou"
);
$ossClient = new OssClient($config);

// Apply rounded corners with a 30-pixel radius.
$image = "image/rounded-corners,r_30";

$options = array(
    OssClient::OSS_FILE_DOWNLOAD => $download_file,
    OssClient::OSS_PROCESS => $image
);

$ossClient->getObject($bucket, $object, $options);

Use the RESTful API

Add the x-oss-process query parameter to a GetObject request.

GET /oss.jpg?x-oss-process=image/rounded-corners,r_30 HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS qn6q**************:77Dv****************