The sharpen parameter increases edge contrast in images stored in Object Storage Service (OSS), making them appear crisper and more defined. Apply sharpening after resizing to recover perceived detail lost during downscaling, or to compensate for slight blur and compression artifacts.
Parameter
Action: sharpen
| Parameter | Valid values | Description |
|---|---|---|
[value] | 50–399 | Degree of sharpness. Higher values produce crisper images. An excessively large value may result in image artifacts. Use 100 for post-resize sharpening. |
URL syntax:
x-oss-process=image/sharpen,<value>Methods
Sharpen a public-read image
For buckets with public-read or public-read-write access, append the x-oss-process query parameter directly to the object URL.
Original (example.jpg, sharpness = 0) | Sharpened (sharpen,100) |
|---|---|
![]() | ![]() |
Processed URL:
https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/sharpen,100Sharpen a private image
For private objects, use an OSS SDK or call the GetObject API with Signature V4 authentication.
All examples below apply image/sharpen,100.
Use OSS SDKs
The following sample code provides examples on how to sharpen a private image by using OSS SDKs for common programming languages. For more information about how to sharpen a private image by using other programming languages, see SDK references.
Java
Requires OSS SDK for Java 3.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 {
// Replace with your bucket's endpoint
String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
// Replace with your bucket's region
String region = "cn-hangzhou";
// Read access 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 {
String style = "image/sharpen,100";
GetObjectRequest request = new GetObjectRequest(bucketName, objectName);
request.setProcess(style);
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());
} catch (ClientException ce) {
System.out.println("Error Message: " + ce.getMessage());
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
}
}PHP
Requires OSS SDK for PHP 2.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 access credentials from environment variables:
// OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET
$provider = new EnvironmentVariableCredentialsProvider();
// Replace with your bucket's endpoint
$endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
$bucket = "examplebucket";
$object = "example.jpg";
// Local path to save the processed image
$download_file = "D:\\dest.jpg";
$config = array(
"provider" => $provider,
"endpoint" => $endpoint,
"signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
"region" => "cn-hangzhou"
);
$ossClient = new OssClient($config);
$style = "image/sharpen,100";
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => $style
);
$ossClient->getObject($bucket, $object, $options);Python
Requires OSS SDK for Python 2.18.4 or later.
# -*- coding: utf-8 -*-
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
# Read access credentials from environment variables:
# OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())
# Replace with your bucket's endpoint
endpoint = 'https://oss-cn-hangzhou.aliyuncs.com'
region = 'cn-hangzhou'
bucket = oss2.Bucket(auth, endpoint, 'examplebucket', region=region)
key = 'example.jpg'
# Local path to save the processed image
new_pic = 'D:\\dest.jpg'
style = 'image/sharpen,100'
bucket.get_object_to_file(key, new_pic, process=style)Go
Requires OSS SDK for Go 3.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 access credentials from environment variables:
// OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET
provider, err := oss.NewEnvironmentVariableCredentialsProvider()
if err != nil {
handleError(err)
}
// Replace with your bucket's endpoint
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)
}
sourceImage := "example.jpg"
// Local path to save the processed image
targetImage := "D://dest.jpg"
style := "image/sharpen,100"
err = bucket.GetObjectToFile(sourceImage, targetImage, oss.Process(style))
if err != nil {
handleError(err)
}
}Use the RESTful API
For custom request handling, call the GetObject operation directly with Signature V4 in the Authorization header. For details, see (Recommended) Include a V4 signature.
GET /oss.jpg?x-oss-process=image/sharpen,100 HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218eWhat's next
For SDK examples in other languages, see SDK references.

