Tous les produits
Search
Centre de documentation

Object Storage Service:Filigrane invisible

Dernière mise à jour :Aug 18, 2026

Pour les images stockées dans un compartiment Object Storage Service (OSS), utilisez la fonctionnalité de filigrane invisible pour ajouter et extraire des filigranes textuels invisibles.

Présentation

Le filigrane invisible intègre des informations textuelles invisibles dans une image sans en altérer la qualité visuelle. Pour récupérer le contenu du filigrane, utilisez l'opération d'extraction de filigrane invisible. L'extraction fonctionne correctement même si l'image a subi certaines altérations, telles que le recadrage, la mise à l'échelle, les gribouillages ou l'inversion des couleurs.

Cas d'utilisation

  • Authentification et traçabilité : déterminez si vos images ont été volées par des attaquants malveillants.

  • Vérification des doublons lors du téléchargement : déterminez si une image téléchargée existe déjà dans une bibliothèque de ressources.

  • Prévention des fuites de ressources : obtenez des informations sur la source d'une fuite à partir du filigrane invisible intégré dans une image diffusée.

Utilisation

  • Ajout d'un filigrane invisible : utilisez la méthode de traitement synchrone (x-oss-process). Une fois le filigrane ajouté, l'image est enregistrée sous forme de nouveau fichier.

  • Extraction d'un filigrane invisible : utilisez la méthode de traitement asynchrone (x-oss-async-process). Le filigrane textuel extrait est inclus dans le message asynchrone.

Prérequis

  • Le service Intelligent Media Management (IMM) est activé.

  • Un projet IMM est créé et lié. Pour plus d'informations sur la liaison d'un projet dans la console OSS, consultez la section Démarrage rapide. Pour plus d'informations sur la liaison d'un projet via une API, consultez la section AttachOSSBucket.

  • Lorsque vous extrayez un filigrane invisible, le compartiment contenant l'image doit se trouver dans la même région que le compartiment utilisé lors de l'ajout du filigrane. Le compartiment doit également être lié au même projet IMM que celui utilisé pour ajouter le filigrane. Sinon, le filigrane ne peut pas être extrait.

Ajouter un filigrane invisible

Action : image/blindwatermark

Étapes d'encodage du filigrane

  1. Encodez le contenu en Base64.

  2. Remplacez certaines parties de l'encodage dans le résultat.

    • Remplacez les signes plus (+) par des traits d'union (-).

    • Remplacez les barres obliques (/) par des underscores (_).

    • Supprimez tous les signes égal (=) à la fin de la chaîne.

Java

Le SDK for Java version 3.17.4 ou ultérieure est requis.

import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.GenericResult;
import com.aliyun.oss.model.ProcessObjectRequest;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Formatter;

public class Demo {
    public static void main(String[] args) throws IOException {
        // In this example, the endpoint is set to China (Hangzhou). Set the endpoint to the actual region.
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // Specify the region ID that corresponds to the endpoint. For example, if the endpoint is oss-cn-hangzhou.aliyuncs.com, set the region to cn-hangzhou.
        String region = "cn-hangzhou";
        // Do not hard-code access credentials in your project. Otherwise, the access credentials may be leaked, which compromises the security of all your resources.
        // In this example, the access credentials are obtained from environment variables. Before you run the sample code, configure the environment variables.
        EnvironmentVariableCredentialsProvider credentialsProvider = new EnvironmentVariableCredentialsProvider();

        // Specify the bucket name. Example: examplebucket.
        String bucketName = "examplebucket";

        // Specify the name of the source image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: sourceDir/source.jpg.
        String sourceImage = "sourceDir/source.jpg";

        // Create an OSSClient instance.
        // When the OSSClient instance is no longer used, call the shutdown method to release the resources.
        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        // Explicitly declare the use of the V4 signature algorithm.
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(credentialsProvider)
                .clientConfiguration(clientBuilderConfiguration)
                .region(region)
                .build();

        try {
            StringBuilder sbStyle = new StringBuilder();
            Formatter styleFormatter = new Formatter(sbStyle);

            // Specify the watermark content.
            String content = "Copyright © Alibaba Cloud";
            // Add a blind watermark.
            // Fix: Use URL-safe Base64 encoding and remove padding.
            String encodedContentStr = java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(content.getBytes(StandardCharsets.UTF_8));
            String styleType = "image/blindwatermark,content_" + encodedContentStr;

            // Specify the name of the processed image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: targetDir/target.jpg.
            String targetImage = "targetDir/target.jpg";
            // Fix: Use URL-safe Base64 encoding and remove padding for targetImage and bucketName.
            styleFormatter.format("%s|sys/saveas,o_%s,b_%s",
                    styleType,
                    java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(targetImage.getBytes(StandardCharsets.UTF_8)),
                    java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(bucketName.getBytes(StandardCharsets.UTF_8)));

            System.out.println(sbStyle.toString());
            ProcessObjectRequest request = new ProcessObjectRequest(bucketName, sourceImage, sbStyle.toString());
            GenericResult processResult = ossClient.processObject(request);

            BufferedReader reader = new BufferedReader(new InputStreamReader(processResult.getResponse().getContent(), StandardCharsets.UTF_8));
            StringBuilder responseContent = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                responseContent.append(line).append("\n");
            }

            reader.close();
            processResult.getResponse().getContent().close();
            System.out.println(responseContent.toString());
        } catch (OSSException oe) {
            System.err.println("Caught an OSSException, which means your request made it to OSS, but was rejected with an error response for some reason.");
            System.err.println("Error Message:" + oe.getErrorMessage());
            System.err.println("Error Code:" + oe.getErrorCode());
            System.err.println("Request ID:" + oe.getRequestId());
            System.err.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.err.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.err.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

Python

Le SDK for Python version 2.18.4 ou ultérieure est requis.

# -*- coding: utf-8 -*-
import base64
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.ProviderAuth(EnvironmentVariableCredentialsProvider())
# Specify the endpoint of the region in which 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 name of the bucket where the source image is stored.
source_bucket_name = 'source_bucket_name'
# Specify the name of the bucket where you want to store the processed image. This bucket must be in the same region as the source bucket.
target_bucket_name = 'target_bucket_name'
# Specify the name of the source image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: sourceDir/source.jpg.
source_image_name = 'sourceDir/source.jpg'

# Create a bucket instance. All file-related methods must be called on the bucket instance.
bucket = oss2.Bucket(auth, endpoint, source_bucket_name)

# Specify the watermark content.
content = 'Copyright © Alibaba Cloud'

# Add a blind watermark.
style = "image/blindwatermark,content_{0}".format(oss2.compat.to_string(base64.urlsafe_b64encode(oss2.compat.to_bytes(content))))

# Specify the name of the processed image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: targetDir/target.jpg.
target_image_name = 'targetDir/target.jpg'
process = "{0}|sys/saveas,o_{1},b_{2}".format(style,
    oss2.compat.to_string(base64.urlsafe_b64encode(oss2.compat.to_bytes(target_image_name))),
    oss2.compat.to_string(base64.urlsafe_b64encode(oss2.compat.to_bytes(target_bucket_name))))
result = bucket.process_object(source_image_name, process)
print(result)

Go

Le SDK for Go version 3.0.2 ou ultérieure est requis.

package main

import (
	"encoding/base64"
	"fmt"
	"os"
	"strings"
	"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.
	// Set yourEndpoint to the endpoint of the bucket. In this example, the endpoint of a bucket in the China (Hangzhou) region is used. Set the endpoint to the actual endpoint.
	client, err := oss.New("https://oss-cn-hangzhou.aliyuncs.com", "", "", oss.SetCredentialsProvider(&provider))
	if err != nil {
		fmt.Println("Error:", err)
		os.Exit(-1)
	}

	// Specify the name of the bucket where the source image is stored.
	bucketName := "srcbucket"
	bucket, err := client.Bucket(bucketName)
	if err != nil {
		handleError(err)
		return
	}

	// Specify the name of the source image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: sourceDir/source.jpg.
	sourceImageName := "sourceDir/source.jpg"

	// Specify the name of the bucket where you want to store the processed image. This bucket must be in the same region as the source bucket.
	targetBucketName := "destbucket"

	// Specify the name of the processed image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: targetDir/target.jpg.
	targetImageName := "targetDir/target.jpg"

	// Specify the watermark content.
	content := "Copyright © Alibaba Cloud"

	// Generate a blind watermark. As required by the documentation, you must remove the trailing equal signs (=).
	encodedContent := strings.TrimRight(base64.URLEncoding.EncodeToString([]byte(content)), "=")
	style := fmt.Sprintf("image/blindwatermark,content_%s", encodedContent)
	// You must also remove the trailing equal signs (=) from the encoded target image name and bucket name.
	encodedImageName := strings.TrimRight(base64.URLEncoding.EncodeToString([]byte(targetImageName)), "=")
	encodedBucketName := strings.TrimRight(base64.URLEncoding.EncodeToString([]byte(targetBucketName)), "=")
	process := fmt.Sprintf("%s|sys/saveas,o_%s,b_%s", style, encodedImageName, encodedBucketName)

	result, err := bucket.ProcessObject(sourceImageName, process)
	if err != nil {
		handleError(err)
	} else {
		fmt.Println(result)
	}
}

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

PHP

Le SDK for PHP version 2.7.0 ou ultérieure est requis.

<?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\OssClient;
use OSS\Core\OssException;

// 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.
$accessKeyId = getenv("OSS_ACCESS_KEY_ID");
$accessKeySecret = getenv("OSS_ACCESS_KEY_SECRET");

// Set yourEndpoint to the endpoint of the bucket. 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 bucket name. Example: examplebucket.
$bucket = "examplebucket";

// Specify the name of the source image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: sourceDir/source.jpg.
$object = "sourceDir/source.jpg";

// Specify the name of the processed image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: targetDir/target.jpg.
$save_object = "targetDir/target.jpg";

function base64url_encode($data)
{
    return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}

try {
    $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false);

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

    $content = "Copyright © Alibaba Cloud";
    // Add a blind watermark to the image.
    $encodedContent = base64url_encode($content);
    $style = "image/blindwatermark,content_$encodedContent";

    $process = $style .
               '|sys/saveas,' .
               'o_' . base64url_encode($save_object) .
               ',b_' . base64url_encode($bucket);

    // Name the processed image example-new.png and save it to the current bucket.
    $result = $ossClient->processObject($bucket, $object, $process);
    // Print the processing result.
    print_r($result);
} catch (OssException $e) {
    echo "Error: " . $e->getMessage();
}
?>

Pour plus d'informations sur l'utilisation d'autres langages, consultez la section Enregistrer sous.

Extraire un filigrane invisible

Action : image/deblindwatermark

Java

Le SDK for Java version 3.17.4 ou ultérieure est requis.

import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.EnvironmentVariableCredentialsProvider;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.AsyncProcessObjectRequest;
import com.aliyun.oss.model.AsyncProcessObjectResult;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Demo {
    public static void main(String[] args) throws IOException {
        // In this example, the endpoint is set to China (Hangzhou). Set the endpoint to the actual region.
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        // Specify the region ID that corresponds to the endpoint. For example, if the endpoint is oss-cn-hangzhou.aliyuncs.com, set the region to cn-hangzhou.
        String region = "cn-hangzhou";
        // Do not hard-code access credentials in your project. Otherwise, the access credentials may be leaked, which compromises the security of all your resources.
        // In this example, the access credentials are obtained from environment variables. Before you run the sample code, configure the environment variables.
        EnvironmentVariableCredentialsProvider credentialsProvider = new EnvironmentVariableCredentialsProvider();

        // Specify the bucket name. Example: examplebucket.
        String bucketName = "target_bucket_name";

        // Specify the name of the source image. If the image is not in the root directory of the bucket, you must specify the full path of the image. Example: sourceDir/source.jpg.
        String sourceKey = "targetDir/target.jpg";

        // The topic of the MNS message.
        String topic = "imm-blindwatermark-test";

        // Create an OSSClient instance.
        // When the OSSClient instance is no longer used, call the shutdown method to release the resources.
        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        // Explicitly declare the use of the V4 signature algorithm.
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(credentialsProvider)
                .clientConfiguration(clientBuilderConfiguration)
                .region(region)
                .build();

        try {
            // Extract the watermark content from the specified image.
            String style = "image/deblindwatermark,s_low,t_text";
            String encodedTopic = Base64.getUrlEncoder().withoutPadding().encodeToString(topic.getBytes(StandardCharsets.UTF_8));
            String process = String.format("%s|sys/notify,topic_%s", style, encodedTopic);

            AsyncProcessObjectRequest request = new AsyncProcessObjectRequest(bucketName, sourceKey, process);
            
            // Call the asynchronous stream processing interface.
            AsyncProcessObjectResult result = ossClient.asyncProcessObject(request);
            System.out.println(result.getRequestId());
            // Obtain and print the TaskId to track the spooling task.
            System.out.println(result.getTaskId());
            

        } catch (OSSException oe) {
            System.err.println("Caught an OSSException, which means your request made it to OSS, but was rejected with an error response for some reason.");
            System.err.println("Error Message:" + oe.getErrorMessage());
            System.err.println("Error Code:" + oe.getErrorCode());
            System.err.println("Request ID:" + oe.getRequestId());
            System.err.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.err.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.err.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

Python

Le SDK for Python version 2.18.4 ou ultérieure est requis.

# -*- coding: utf-8 -*-
import base64
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
# Specify the endpoint of the region in which 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'
# 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.ProviderAuth(EnvironmentVariableCredentialsProvider())
# Specify the bucket name.
bucket_name = 'target_bucket_name'
# Specify the name of the watermarked image file.
source_key = 'targetDir/target.jpg'
# Specify the topic of the MNS message.
topic = 'imm-blindwatermark-test'

# Create a bucket instance. All file-related methods must be called on the bucket instance.
bucket = oss2.Bucket(auth, endpoint, bucket_name)

# Extract the watermark content from the specified image.
style = 'image/deblindwatermark,s_low,t_text'
process = "{0}|sys/notify,topic_{1}".format(style,
oss2.compat.to_string(base64.urlsafe_b64encode(oss2.compat.to_bytes(topic))).replace('=', ''))

# Call the asynchronous stream processing interface.
result = bucket.async_process_object(source_key, process)
# The unique ID of the OSS API request, used for tracking and troubleshooting.
print(result.request_id)
# The unique ID of the task, used to track the spooling task.
print(result.task_id)

Go

Le SDK for Go version 3.0.2 ou ultérieure est requis.

package main

import (
    "encoding/base64"
    "fmt"
    "os"
    "strings"
    "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.
    endpoint := "https://oss-cn-hangzhou.aliyuncs.com"
    client, err := oss.New(endpoint, "", "", oss.SetCredentialsProvider(provider))
    if err != nil {
        fmt.Println("Error:", err)
        os.Exit(-1)
    }

    // Specify the bucket name.
    bucketName := "target_bucket_name" 
    bucket, err := client.Bucket(bucketName)
    if err != nil {
        handleError(err)
        return
    }

    // Specify the name of the watermarked image file.
    sourceKey := "targetDir/target.jpg"

    // Specify the topic of the MNS message.
    topic := "imm-blindwatermark-test"

    // Extract the watermark content from the specified image.
    style := "image/deblindwatermark,s_low,t_text"
    encodedTopic := strings.TrimRight(base64.URLEncoding.EncodeToString([]byte(topic)), "=")
    process := fmt.Sprintf("%s|sys/notify,topic_%s", style, encodedTopic)

    // Call the asynchronous stream processing interface.
    result, err := bucket.AsyncProcessObject(sourceKey, process)
    if err != nil {
        handleError(err)
    } else {
        fmt.Println(result.RequestID) // The unique ID of the OSS API request.
        fmt.Println(result.TaskId) // The unique ID of the task, used to track the spooling task.
    }
}

func handleError(err error) {
    fmt.Fprintf(os.Stderr, "Error: %v\n", err)
    os.Exit(-1)
}

PHP

Le SDK for PHP version 2.7.0 ou ultérieure est requis.

if (is_file(__DIR__ . '/../autoload.php')) {
    require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
    require_once __DIR__ . '/../vendor/autoload.php';
}

// 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.
$accessKeyId = getenv("OSS_ACCESS_KEY_ID");
$accessKeySecret = getenv("OSS_ACCESS_KEY_SECRET");

// In this example, the endpoint is set to China (Hangzhou). Set the endpoint to the actual region.
$endpoint = 'https://oss-cn-hangzhou.aliyuncs.com';

// Specify the bucket name.
$bucketName = 'target_bucket_name'; 

// Specify the name of the watermarked image file.
$sourceKey = 'targetDir/target.jpg';

function base64_url_encode($input) {
    return strtr(base64_encode($input), '+/', '-_');
}

try {
    // Create an OSSClient instance.
    $client = new OssClient($accessKeyId, $accessKeySecret, $endpoint);

    // Specify the topic of the MNS message.
    $topic = 'imm-blindwatermark-test';

    // Extract the watermark content from the specified image.
    $style = 'image/deblindwatermark,s_low,t_text';
    $encodedTopic = str_replace('=', '', base64_url_encode($topic));
    $process = sprintf('%s|sys/notify,topic_%s', $style, $encodedTopic);

    // Call the asynchronous stream processing interface.
    $result = $client->asyncProcessObject($bucketName, $sourceKey, $process);
    
    // Parse the returned JSON string.
    $decodedResult = json_decode($result, true);
    
    echo "Request ID: " . $decodedResult['RequestId'] . "\n"; // The unique ID of the OSS API request.
    echo "TaskId: " . $decodedResult['TaskId'] . "\n"; // The unique ID of the task, used to track the spooling task.

} catch (OssException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>

Pour plus d'informations sur l'utilisation d'autres SDK, consultez la section Traitement asynchrone.

Paramètres

Ajouter un filigrane invisible

Action : image/blindwatermark

Paramètre

Obligatoire

Description

Valeurs valides

content

Non

Le texte du filigrane doit être encodé en Base64 sécurisé pour les URL. Vous pouvez utiliser l'outil d'encodage de filigrane pour encoder le texte. Par exemple, si le texte est Alibaba Cloud Copyright, le texte encodé est 6Zi_6YeM5LqR54mI5p2D5omA5pyJ.

La chaîne de caractères du filigrane avant l'encodage Base64 peut comporter jusqu'à 256 caractères.

s

Non

La force du filigrane. Une force plus élevée offre une meilleure résistance aux attaques, mais entraîne une distorsion plus visible de l'image.

  • low (par défaut) : faible force.

  • medium : force moyenne.

  • high : force élevée.

q

Non

La qualité de l'image filigranée en sortie. Une qualité plus élevée entraîne une taille d'image plus grande et une meilleure qualité d'extraction du filigrane.

Remarque

Ce paramètre prend effet uniquement si l'image d'entrée est au format JPG.

Valeur par défaut : 90. Valeurs valides : 70 à 100.

Le paramètre sys/saveas est également utilisé lorsque vous ajoutez un filigrane invisible à une image. Pour plus d'informations, consultez la section Enregistrer une image à un emplacement spécifié.

Extraire un filigrane invisible

Action : image/deblindwatermark

Paramètre

Obligatoire

Description

Valeurs valides

s

Non

Le niveau d'extraction du filigrane. Un niveau plus élevé prend plus de temps, mais offre de meilleurs résultats.

  • low (par défaut) : niveau faible.

  • medium : niveau moyen.

  • high : niveau élevé.

t

Non

Le type de filigrane intégré.

Texte : text

Le paramètre notify est également utilisé lorsque vous extrayez un filigrane invisible. Pour plus d'informations, consultez la section Notifications.

Opérations API associées

Si votre application nécessite un niveau élevé de personnalisation, envoyez directement des requêtes REST API. Pour ce faire, vous devez écrire manuellement le code de calcul de la signature. Pour plus d'informations sur le calcul de l'en-tête de requête Authorization, consultez la section Signature V4 (recommandée). Pour ajouter ou extraire un filigrane invisible, envoyez une requête POST et incluez les paramètres dans le corps de la requête.

Ajouter un filigrane invisible

Traitez les images en ajoutant le paramètre x-oss-process à une requête PostObject. Pour plus d'informations, consultez la section PostObject.

Exemple de traitement

POST /example.jpg?x-oss-process   HTTP/1.1
Host: image-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: SignatureValue

// The watermark content is "Alibaba Cloud Copyright", the watermark strength is low, the output image quality is 90, and the watermarked image is saved to oss://image-demo/outobjprefix.jpg.
x-oss-process=image/blindwatermark,content_6Zi_6YeM5LqR54mI5p2D5omA5pyJ,s_low,q_90|sys/saveas,b_aW1hZ2UtZGVtbw,o_b3V0b2JqcHJlZml4LmpwZw

Extraire un filigrane invisible

Traitez les images en ajoutant des paramètres de mise à l'échelle d'image à l'API PostObject. Pour plus d'informations, consultez la section PostObject.

Exemple de traitement

POST /outobjprefix.jpg?x-oss-async-process HTTP/1.1
Host: image-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: SignatureValue

// Parse the watermark that was added in the previous step. The message topic is doc-images.
x-oss-async-process=image/deblindwatermark|sys/notify,topic_ZG9jLWltYWdlcw

Remarques

  • La fonctionnalité de filigrane invisible prend uniquement en charge les images aux formats JPG, PNG, BMP, WebP et TIFF.

  • La largeur et la hauteur minimales d'une image sont de 80 pixels. La largeur et la hauteur maximales sont de 10 000 pixels.

  • Le rapport entre le côté le plus court et le côté le plus long doit être supérieur à 1:2.

  • La fonctionnalité de filigrane invisible ne prend pas en charge les images entièrement noires, entièrement blanches ou de faible résolution. Par exemple, les images d'une résolution inférieure à 200 × 200 pixels peuvent ne pas être prises en charge, bien qu'il ne s'agisse pas d'une limite stricte.

  • Seuls les filigranes textuels sont pris en charge.

  • L'accès anonyme n'est pas pris en charge.