Tous les produits
Search
Centre de documentation

Object Storage Service:Styles d'image

Dernière mise à jour :Aug 18, 2026

Créez des styles d'image dans OSS pour combiner plusieurs opérations de traitement, telles que le redimensionnement, le recadrage, la rotation et l'ajout de filigranes, puis appliquez-les aux images stockées dans un bucket.

Créer un style

Chaque bucket prend en charge jusqu'à 50 styles d'image, qui s'appliquent uniquement aux images contenues dans ce bucket. Pour en créer davantage, contactez le support technique.

Console OSS

  1. Connectez-vous à la console OSS.

  2. Dans le volet de navigation de gauche, cliquez sur Buckets. Sur la page qui s'affiche, cliquez sur le nom du bucket cible.

  3. Dans le volet de navigation de gauche, choisissez Data Processing > IMG.

  4. Sur la page IMG, cliquez sur Create Style.

  5. Dans le panneau Create Style, configurez le style en utilisant l'une des méthodes suivantes.

    • Basic Settings : utilisez l'interface graphique pour sélectionner les méthodes de traitement et configurez les paramètres suivants.

      Catégorie

      Paramètre

      Description

      Nom de la règle

      Rule Name

      Nom du style. Doit comporter entre 1 et 63 caractères : lettres, chiffres, traits de soulignement (_), traits d'union (-) et points (.).

      Image

      format conversion

      Convertit le format de l'image. Sélectionnez Original pour conserver le format actuel.

      Options : Original, jpg, jpeg, png, bmp, gif, webp ou tiff.

      progressive display

      Affiche un contour flou qui devient progressivement plus net au chargement de l'image.

      Remarque

      Cette fonctionnalité ne s'applique qu'aux images au format JPG.

      auto orientation

      Fait pivoter l'image selon ses données EXIF avant le redimensionnement.

      image quality

      Sélectionnez une option de qualité d'image : Relative, Absolute ou Uncompressed.

      Transformation de la qualité.

      Resizing

      Resize Type

      Sélectionnez une méthode de redimensionnement : Do Not Use Thumbnail, Proportional Scale Down, Proportional Scale Up ou Fixed Width and Height.

      Effects

      Image brightness

      Faites glisser le curseur pour ajuster la luminosité.

      0 = original. Les valeurs négatives assombrissent l'image ; les valeurs positives l'éclaircissent.

      Image contrast

      Faites glisser le curseur pour ajuster le contraste.

      0 = original. Les valeurs négatives réduisent le contraste ; les valeurs positives l'augmentent.

      Image sharpen

      Améliore la netteté de l'image.

      Activez la netteté, puis faites glisser le curseur pour ajuster le niveau.

      Image blur

      Activez le flou, puis faites glisser les curseurs pour définir le rayon de flou et l'écart type.

      Image rotation

      Faites glisser le curseur pour définir l'angle de rotation.

      Watermarking

      Watermarking

      Ajoutez un filigrane image, un filigrane texte ou aucun filigrane.

    • Advanced Settings : spécifiez les opérations de traitement sous forme de chaîne de paramètres au format image/action1,parame_value1/action2,parame_value2/.... Paramètres pris en charge : Paramètres de traitement d'image.

      Exemple : image/resize,p_63/quality,q_90 redimensionne l'image à 63 % de sa taille d'origine et définit la qualité relative à 90 %.

      Remarque

      Pour combiner des filigranes image et texte dans un même style, utilisez Advanced Settings.

  6. Cliquez sur OK.

SDK

Utilisez les SDK pour créer des styles d'image. Voici des exemples en Python et Go :

Python

# -- coding: utf-8 -- import oss2 from oss2.credentials import EnvironmentVariableCredentialsProvider # Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider()) # Specify the endpoint of the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. endpoint = "https://oss-cn-hangzhou.aliyuncs.com" # Specify the region of the endpoint. Example: cn-hangzhou. This parameter is required if you use the V4 signature algorithm. region = "cn-hangzhou" # Replace examplebucket with the name of the bucket. bucket = oss2.Bucket(auth, endpoint, "examplebucket", region=region) # Specify the name of the image style, such as imagestyle. style = 'imagestyle' # Specify the operation of the image style, such as resizing the image to a width of 200 pixels. content = 'image/resize,w_200' # Create an image style. result = bucket.put_bucket_style(style, content) print('The style is created. The status code is: ' + str(result.status))

Go

package main import ( "fmt" "os" "github.com/aliyun/aliyun-oss-go-sdk/oss" ) func main() { // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. provider, err := oss.NewEnvironmentVariableCredentialsProvider() if err != nil { fmt.Println("Error:", err) os.Exit(-1) } // Create an OSSClient instance. // Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. Specify your actual endpoint. // Specify the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou. Specify the actual region. clientOptions := []oss.ClientOption{oss.SetCredentialsProvider(&provider)} clientOptions = append(clientOptions, oss.Region("yourRegion")) // Specify the version of the signature algorithm. clientOptions = append(clientOptions, oss.AuthVersion(oss.AuthV4)) client, err := oss.New("yourEndpoint", "", "", clientOptions...) if err != nil { fmt.Println("Error:", err) os.Exit(-1) } // Specify the name of the bucket. Example: examplebucket. bucketName := "examplebucket" // Specify the operation of the image style, such as scaling the source image down to 63 % and setting the relative quality of the image to 90 %. styleContent := "image/resize,p_63/quality,q_90" // Specify the name of the image style. Example: imagestyle. styleName := "imagestyle" err = client.PutBucketStyle(bucketName,styleName, styleContent) if err != nil { fmt.Println("Error:", err) os.Exit(-1) } fmt.Println("Bucket Style Set Success!") }

ossutil

Utilisez ossutil pour créer des styles d'image. Installer ossutil.

La commande suivante crée un style d'image nommé imageStyle pour le bucket examplebucket :

ossutil api put-style --bucket examplebucket --style-name imageStyle --style "{\"Content\":\"image/resize,p_50\"}"

put-style.

Règles d'utilisation des styles

Après avoir configuré un style d'image, appliquez-le pour traiter les images via une URL de traitement d'image ou un SDK OSS.

Important

Si vous utilisez un style pour traiter une image animée telle qu'un GIF, ajoutez le paramètre /format,gif au style. Sinon, la sortie risque d'être statique.

Utiliser une URL de traitement d'image

Ajoutez le style à l'URL de l'image : http(s)//:BucketName.Endpoint/ObjectName?x-oss-process=style/<StyleName>. Exemple : https://oss-console-img-demo-cn-hangzhou-3az.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=style/small.

Un séparateur personnalisé remplace ?x-oss-process=style/ pour raccourcir les URL. Par exemple, avec un point d'exclamation (!) comme séparateur, l'URL devient http(s)//:BucketName.Endpoint/ObjectName!StyleName. Définir des séparateurs personnalisés.

Associez un domaine personnalisé à votre bucket pour obtenir des URL encore plus courtes. Par exemple, avec example.com associé, l'URL devient https://example.com/example.jpg!small. Les domaines personnalisés permettent également la prévisualisation en ligne. Mapper des noms de domaine personnalisés.

Utiliser un SDK OSS

Utilisez un SDK OSS pour appliquer des styles d'image. Voici des exemples pour les langages courants. Pour les autres langages, consultez la présentation des SDK.

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 {
        // In this example, the endpoint of the China (Hangzhou) region is used. Specify your actual endpoint. 
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // Specify the name of the bucket. Example: examplebucket. 
        String bucketName = "examplebucket";
        // Specify the full path of the object. Do not include the bucket name in the full path. 
        String objectName = "exampleobject.jpg";
        // Specify the full path to which you want to save the processed image. Example: D:\\localpath\\example-new.jpg. If a file with the same name already exists in the path, the processed image overwrites the file. Otherwise, the processed image is saved in the path. 
        String pathName = "D:\\localpath\\example-new.jpg";
        // Specify the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou.
        String region = "cn-hangzhou";

        // Create an OSSClient instance.
        // Call the shutdown method to release resources when the OSSClient is no longer in use. 
        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);        
        OSS ossClient = OSSClientBuilder.create()
        .endpoint(endpoint)
        .credentialsProvider(credentialsProvider)
        .clientConfiguration(clientBuilderConfiguration)
        .region(region)               
        .build();

        try {
            // Use a custom image style to process the image. 
            // In this example, replace yourCustomStyleName with the name of the image style that you created in the OSS console. 
            String style = "style/yourCustomStyleName";
            GetObjectRequest request = new GetObjectRequest(bucketName, objectName);
            request.setProcess(style);
            // Name the processed image example-new.jpg and save the image to your local computer. 
            // If you specify only the name of a local file such as example-new.jpg without specifying the local path of the file, the processed image is saved to the local path of the project to which the sample program belongs. 
            ossClient.getObject(request, new File(pathName));
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            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("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}
<?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;
// Obtain access credentials from environment variables. Before you run this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set.
$provider = new EnvironmentVariableCredentialsProvider();
// Set yourEndpoint to the endpoint of the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com.
$endpoint = "yourEndpoint";
// Set the bucket name. For example, examplebucket.
$bucket= "examplebucket";
// Set the full path of the object. For example, exampledir/exampleobject.jpg. The full path cannot include the bucket name.
$object = "exampledir/exampleobject.jpg";
// Set the full path of the local file. For example, D:\\localpath\\example-new.jpg. If the specified local file exists, it is overwritten. If it does not exist, a new file is created.
// If you specify only the local file name, such as example-new.jpg, without a full path, the file is saved by default to the local path of the project where the sample program resides.
$download_file = "D:\\localpath\\example-new.jpg";

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

// If the source image is not in the specified bucket, upload the image to the bucket.
// $ossClient->uploadFile($bucket, $object, "D:\\localpath\\exampleobject.jpg");

// Process the image using a custom style.
// Set yourCustomStyleName to the name of the image style that you created in the OSS console.
$style = "style/yourCustomStyleName";

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

// Name the processed image example-new.jpg and save it to a local path.
$ossClient->getObject($bucket, $object, $options);

// After the image is processed, delete the source image from the bucket if it is no longer needed.
// $ossClient->deleteObject($bucket, $object);                              
const OSS = require('ali-oss');

const client = new OSS({
  // Set yourregion to the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set Region to oss-cn-hangzhou.
  region: 'yourregion',
  // Obtain access credentials from environment variables. Before you run this code sample, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
  accessKeyId: process.env.OSS_ACCESS_KEY_ID,
  accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
  authorizationV4: true,
  // Set yourbucketname to the bucket name.
  bucket: 'yourbucketname'
});

// Scale the image to a fixed width and height of 100 pixels.
async function scale() {
  try {
    const result = await client.get('example.jpg', './example-resize.jpg', { process: 'image/resize,m_fixed,w_100,h_100'});
  } catch (e) {
    console.log(e);
  }
}

scale()

// Crop the image to a width and height of 100 pixels, starting from the coordinate (100, 100).
async function cut() {
  try {
     const result = await client.get('example.jpg', './example-crop.jpg', { process: 'image/crop,w_100,h_100,x_100,y_100,r_1'});
  } catch (e) {
    console.log(e)
  }
}

cut()

// Rotate the image 90 degrees.
async function rotate() {
  try {
    const result = await client.get('example.jpg', './example-rotate.jpg', { process: 'image/rotate,90'});
  } catch (e) {
    console.log(e);
  }
}

rotate()

// Sharpen the image. The sharpening parameter is 100.
async function sharpen() {
  try {
    const result = await client.get('example.jpg', './example-sharpen.jpg', { process: 'image/sharpen,100'});
  } catch (e) {
    console.log(e);
  }
}

sharpen()

// Add a watermark to the image.
async function watermark() {
  try {
    const result = await client.get('example.jpg', './example-watermark.jpg', { process: 'image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ'});
  } catch (e) {
    console.log(e);
  }
}

watermark()

// Convert the image format.
async function format() {
  try {
    const result = await client.get('example.jpg', './example-format.jpg', { process: 'image/format,png'});
  } catch (e) {
    console.log(e);
  }
}

format()

// Obtain image information.
async function info() {
  try {
    const result = await client.get('example.jpg', './example-info.txt', {process: 'image/info'});
  } catch (e) {
    console.log(e);
  }
}

info()
# -*- coding: utf-8 -*-
import os
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider

# Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())

# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. 
endpoint = "https://oss-cn-hangzhou.aliyuncs.com"
# Specify the ID of the region that maps to the endpoint. Example: cn-hangzhou. This parameter is required if you use the signature algorithm V4.
region = "cn-hangzhou"

# Specify the name of the bucket. 
bucket = oss2.Bucket(auth, endpoint, "examplebucket", region=region)

# Specify the name of the bucket in which the source image is stored. Example: examplebucket. 
bucket_name = 'examplebucket'
# Specify the name of the source image. If the image is not stored in the root directory of the bucket, you must specify the path of the image. Example: example/example.jpg. 
key = 'exampledir/example.jpg'
# Specify the name of the processed image. 
new_pic = 'exampledir/newexample.jpg'

# If the image that you want to process does not exist in the specified bucket, you must upload the image that is stored in the local path of the bucket. 
# bucket.put_object_from_file(key, 'D:\\localpath\\example.jpg')

# Use a custom image style to process the image. Set yourCustomStyleName to the name of the image style that you created in the OSS console. 
style = 'style/yourCustomStyleName'
# Save the processed image to your local computer. 
bucket.get_object_to_file(key, new_pic, process=style)
# After the image is processed, you can delete the source image from the bucket if you no longer need the image. 
# bucket.delete_object(key)
# If you no longer need the processed image, you can delete the image. 
# os.remove(new_pic)
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() {
	// Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
	provider, err := oss.NewEnvironmentVariableCredentialsProvider()
	if err != nil {
		fmt.Println("Error:", err)
		os.Exit(-1)
	}
	// Create an OSSClient instance. 
	// Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. Specify your actual endpoint. 
	// Specify the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the region to cn-hangzhou. Specify the actual region.
	clientOptions := []oss.ClientOption{oss.SetCredentialsProvider(&provider)}
	clientOptions = append(clientOptions, oss.Region("yourRegion"))
	// Specify the version of the signature algorithm.
	clientOptions = append(clientOptions, oss.AuthVersion(oss.AuthV4))
	client, err := oss.New("yourEndpoint", "", "", clientOptions...)
	if err != nil {
		fmt.Println("Error:", err)
		os.Exit(-1)
	}

	// Specify the name of the bucket in which the source image is stored. Example: examplebucket. 
	bucketName := "examplebucket"
	bucket, err := client.Bucket(bucketName)
	if err != nil {
		HandleError(err)
	}
	// Specify the name of the source image. If the source image is not stored in the root directory of the bucket, you must specify the full path of the image. Example: example/example.jpg. 
	sourceImageName := "example/example.jpg"
	// Save the processed image as newexample.jpg to your local computer. 
	targetImageName := "D:\\localpath\\newexample.jpg"
	// Use an image style to process the image. Set yourCustomStyleName to the name of the image style that you created in the OSS console. 
	style := "style/yourCustomStyleName"
	// Save the processed image to your local computer. 
	err = bucket.GetObjectToFile(sourceImageName, targetImageName, oss.Process(style))
	if err != nil {
		HandleError(err)
	}
}
#include <alibabacloud/oss/OssClient.h>
using namespace AlibabaCloud::OSS;

int main(void)
{
    /* Initialize the OSS account information. */
    
    /* Set yourEndpoint to the Endpoint of the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the Endpoint to https://oss-cn-hangzhou.aliyuncs.com. */
    std::string Endpoint = "yourEndpoint";
    /* Set yourRegion to the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the Region to cn-hangzhou. */
    std::string Region = "yourRegion";
    /* Specify the name of the bucket that stores the source image, for example, examplebucket. */
    std::string BucketName = "examplebucket";
    /* Specify the name of the source image. If the image is not in the root directory of the bucket, include the full path, for example, exampledir/example.jpg. */
    std::string ObjectName = "exampledir/example.jpg";

     /* Initialize network resources. */
    InitializeSdk();

    ClientConfiguration conf;
    conf.signatureVersion = SignatureVersionType::V4;
    /* Obtain access credentials from environment variables. Before you run this sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set. */
    auto credentialsProvider = std::make_shared<EnvironmentVariableCredentialsProvider>();
    OssClient client(Endpoint, credentialsProvider, conf);
    client.SetRegion(Region);

    /* Process the image using an image style. Set yourCustomStyleName to the name of the image style that you created in Step 1. */
    std::string Process = "style/yourCustomStyleName";
    GetObjectRequest request(BucketName, ObjectName);
    request.setProcess(Process);
    auto outcome = client.GetObject(request);
    if (outcome.isSuccess()) {
    std::cout << "Image processed successfully." << std::endl;
    } else {
    std::cout << "Failed to process image. Error code: " << outcome.error().Code()
              << ", Message: " << outcome.error().Message()
              << ", RequestId: " << outcome.error().RequestId() << std::endl;
    }
  
    /* Release network resources. */
    ShutdownSdk();
    return 0;
}
#include "oss_api.h"
#include "aos_http_io.h"
/* Replace yourEndpoint with the Endpoint of the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the Endpoint to https://oss-cn-hangzhou.aliyuncs.com. */
const char *endpoint = "yourEndpoint";
/* Replace with your bucket name, for example, examplebucket. */
const char *bucket_name = "examplebucket";
/* Replace with the full path of the object. The full path cannot contain the bucket name. For example, exampledir/exampleobject.txt. */
const char *object_name = "exampledir/exampleobject.txt";
/* Replace yourRegion with the region where the bucket is located. For example, if the bucket is in the China (Hangzhou) region, set the region to cn-hangzhou. */
const char *region = "yourRegion";
void init_options(oss_request_options_t *options)
{
    options->config = oss_config_create(options->pool);
    /* Initialize an aos_string_t type with a char* string. */
    aos_str_set(&options->config->endpoint, endpoint);
    /* Obtain access credentials from environment variables. Before running this sample code, make sure the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are set. */
    aos_str_set(&options->config->access_key_id, getenv("OSS_ACCESS_KEY_ID"));
    aos_str_set(&options->config->access_key_secret, getenv("OSS_ACCESS_KEY_SECRET"));
    // Configure the following two additional parameters.
    aos_str_set(&options->config->region, region);
    options->config->signature_version = 4;
    /* Specifies whether a CNAME is used. 0 indicates that no CNAME is used. */
    options->config->is_cname = 0;
    /* Set network parameters, such as the timeout period. */
    options->ctl = aos_http_controller_create(options->pool, 0);
}
int main(int argc, char *argv[])
{
    /* Call the aos_http_io_initialize method at the program entry to initialize global resources such as the network and memory. */
    if (aos_http_io_initialize(NULL, 0) != AOSE_OK) {
        exit(1);
    }
    /* The memory pool (pool) for memory management is equivalent to apr_pool_t. The implementation code is in the apr library. */
    aos_pool_t *pool;
    /* Create a new memory pool. The second parameter is NULL, which indicates that the new pool does not inherit from another memory pool. */
    aos_pool_create(&pool, NULL);
    /* Create and initialize options. This parameter includes global configuration information such as endpoint, access_key_id, access_key_secret, is_cname, and curl. */
    oss_request_options_t *oss_client_options;
    /* Allocate memory from the memory pool to options. */
    oss_client_options = oss_request_options_create(pool);
    /* Initialize the client options oss_client_options. */
    init_options(oss_client_options);
    /* Initialize parameters. */
    aos_string_t bucket;
    aos_string_t object;
    aos_string_t file;
    aos_table_t *headers = NULL;
    aos_table_t *params = NULL;
    aos_table_t *resp_headers = NULL;
    aos_status_t *resp_status = NULL;
    aos_str_set(&bucket, bucket_name);
    aos_str_set(&object, object_name);
    /* Specify an image style. */
    params = aos_table_make(pool, 1);
    /* Replace yourCustomStyleName with the name of the image style that you created in Step 1. */
    apr_table_set(params, OSS_PROCESS, "style/yourCustomStyleName");
    /* Save the processed image to a local file. */
    aos_str_set(&file, "yourLocalFileName");
    resp_status = oss_get_object_to_file(oss_client_options, &bucket, &object, headers, params, &file, &resp_headers);
    if (aos_status_is_ok(resp_status)) {
        printf("get object to file succeeded\n");
    } else {
        printf("get object to file failed\n");  
    }
    /* Release the memory pool. This is equivalent to releasing the memory allocated to resources during the request. */
    aos_pool_destroy(pool);
    /* Release the previously allocated global resources. */
    aos_http_io_deinitialize();
    return 0;
}

Importer et exporter des styles

Exportez des styles depuis un bucket et importez-les dans un autre afin de réutiliser les styles entre différents buckets.

  1. Exportez les styles depuis le bucket source.

    1. Sur la page de gestion du bucket source, choisissez Data Processing > IMG.

    2. Sur la page IMG, sélectionnez le style cible et cliquez sur Export Style.

  2. Importez les styles dans le bucket de destination.

    1. Sur la page de gestion du bucket de destination, choisissez Data Processing >IMG.

    2. Sur la page IMG, cliquez sur Import Style.

    3. Dans la boîte de dialogue qui s'affiche, sélectionnez le fichier de style exporté et cliquez sur Open.

      Les styles importés sont prêts à être utilisés sur les images du bucket de destination.

Opérations API associées

Pour un contrôle total, appelez directement les API REST. Vous devez calculer manuellement la signature de la requête. PutStyle.

FAQ

Les styles d'image sont-ils gratuits ?

Les styles d'image sont gratuits. Le traitement d'image entraîne des frais lorsque les styles sont appliqués. Consultez la section Facturation.

Références