Image quality assessment scores the visual quality of an image on a scale from 0 to 1, where 0 indicates the lowest quality and 1 indicates the highest quality. The score aggregates multiple dimensions—resolution, noise, distortion, color saturation, and exposure—into a single value. Use the score to automate cover image selection, filter low-quality images from a library, or choose video thumbnails without manually reviewing each image.
Use cases
Cover image selection: Pick visually appealing images for articles or product listings to improve click-through rates.
Video thumbnail selection: Identify the sharpest, best-exposed frame to use as a video thumbnail.
Low-quality image filtering: Automatically detect and remove blurry, distorted, or noisy images from an image library to reduce storage waste and improve browsing experience.
Prerequisites
Before you begin, ensure that you have:
Intelligent Media Management (IMM) activated. See Activate IMM.
An OSS bucket associated with an IMM project. See Getting started (OSS console) or AttachOSSBucket (API).
The required permissions. See Permissions.
Usage notes
Image quality assessment supports only synchronous processing (
x-oss-process).Anonymous access is denied.
Parameters
Action: image/score
The response contains a single field, ImageScore.OverallQualityScore, with a value between 0 and 1. A score close to 1 means the image ranks highly across all evaluated dimensions (resolution, noise, distortion, color saturation, and exposure). A score close to 0 means the image is poor quality across most dimensions—for example, blurry, heavily distorted, or severely underexposed.
For full response field definitions, see DetectImageScore.
Use OSS SDKs
All SDK examples below use image/score as the process parameter value to request an image quality score. Credentials are read from environment variables—set OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET before running the code.
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.
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())
# Specify the endpoint and region.
endpoint = 'https://oss-cn-hangzhou.aliyuncs.com'
region = 'cn-hangzhou'
bucket = oss2.Bucket(auth, endpoint, 'examplebucket', region=region)
# Specify the object key. For objects not in the bucket root, use the full path.
# Example: exampledir/example.jpg
key = 'example.jpg'
try:
# Submit the image quality assessment request.
result = bucket.get_object(key, process='image/score')
print(result.read().decode('utf-8'))
except oss2.exceptions.OssError as e:
print("Error:", e)Java
Requires OSS SDK for Java V3.17.4 or later.
import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.auth.CredentialsProviderFactory;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.GetObjectRequest;
import com.aliyuncs.exceptions.ClientException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class Demo {
public static void main(String[] args) throws ClientException {
// Specify the endpoint of the region where the bucket is located.
String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
// Specify the region ID. Example: cn-hangzhou.
String region = "cn-hangzhou";
// Read credentials from environment variables.
EnvironmentVariableCredentialsProvider credentialsProvider =
CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
// Specify the bucket name and object key.
String bucketName = "examplebucket";
String key = "example.jpg";
// Create an OSSClient instance with Signature Version 4.
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(credentialsProvider)
.clientConfiguration(clientBuilderConfiguration)
.region(region)
.build();
try {
// Submit the image quality assessment request.
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key);
getObjectRequest.setProcess("image/score");
OSSObject ossObject = ossClient.getObject(getObjectRequest);
// Read and print the score.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = ossObject.getObjectContent().read(buffer)) != -1) {
baos.write(buffer, 0, bytesRead);
}
System.out.println(baos.toString("UTF-8"));
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
} finally {
ossClient.shutdown();
}
}
}Go
Requires OSS SDK for Go V3.0.2 or later.
package main
import (
"fmt"
"io"
"os"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
func main() {
// Read credentials from environment variables.
provider, err := oss.NewEnvironmentVariableCredentialsProvider()
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Create an OSSClient instance with Signature Version 4.
client, err := oss.New(
"https://oss-cn-hangzhou.aliyuncs.com", "", "",
oss.SetCredentialsProvider(&provider),
oss.AuthVersion(oss.AuthV4),
oss.Region("cn-hangzhou"),
)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
bucket, err := client.Bucket("examplebucket")
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Submit the image quality assessment request.
body, err := bucket.GetObject("example.jpg", oss.Process("image/score"))
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
defer body.Close()
data, err := io.ReadAll(body)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
fmt.Println(string(data))
}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;
try {
// Read credentials from environment variables.
$provider = new EnvironmentVariableCredentialsProvider();
$config = [
"provider" => $provider,
"endpoint" => 'https://oss-cn-hangzhou.aliyuncs.com',
"signatureVersion" => OssClient::OSS_SIGNATURE_VERSION_V4,
"region" => "cn-hangzhou",
];
$ossClient = new OssClient($config);
// Submit the image quality assessment request.
$options[$ossClient::OSS_PROCESS] = "image/score";
$result = $ossClient->getObject('examplebucket', 'example.jpg', $options);
var_dump($result);
} catch (OssException $e) {
printf($e->getMessage() . "\n");
}Use the RESTful API
For high-customization use cases, call the API directly. Include the Authorization header computed using Signature version 4 (recommended). Pass the process instruction via the x-oss-process query parameter in a GetObject request.
Sample request
GET /example.jpg?x-oss-process=image/score HTTP/1.1
Host: image-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 21 Jul 2023 08:28:33 GMT
Authorization: SignatureValueSample response
HTTP/1.1 200 OK
Server: AliyunOSS
Date: Fri, 21 Jul 2023 08:28:34 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 96
Connection: keep-alive
x-oss-request-id: 64BA41B2F326DB30370FEBC9
ETag: "2CE2EA370531B7CC1D23BE6015CF5DA5"
Last-Modified: Mon, 10 Jul 2023 13:07:30 GMT
x-oss-object-type: Normal
x-oss-hash-crc64ecma: 13420962247653419692
x-oss-storage-class: Standard
x-oss-ec: 0048-00000104
Content-Disposition: attachment
x-oss-force-download: true
x-oss-server-time: 466
{
"ImageScore": {
"OverallQualityScore": 0.705
},
"RequestId": "E4B48BE7-46D9-589D-AB6D-C16E9A09A075"
}OverallQualityScore is a float between 0 and 1. Higher values indicate better image quality.