tencent cloud

All product documents
Cloud Infinite
Blind Watermark
Last updated: 2024-02-29 16:13:43
Blind Watermark
Last updated: 2024-02-29 16:13:43

Overview

This document provides an overview of APIs and SDK code samples for blind watermarking.
API
Description
Blind watermarking
Adds blind watermark to or extracts blind watermark from local image and uploads it to bucket

Adding Blind Watermark During Upload

Feature description

This API is used to add a blind watermark when uploading images.

Method prototype

CosResult PutImage(const PutImageByFileReq& request, PutImageByFileResp* response);

Sample request

qcloud_cos::CosConfig config("./config.json");
qcloud_cos::CosAPI cos(config);
std::string bucket_name = "examplebucket-1250000000";

PutImageByFileReq req(bucket_name, object_name, local_file);
PutImageByFileResp resp;

PicOperation pic_operation;
PicRules rule;
// File storage path
rule.fileid = "/" + object_name + "_watermark";
// URL-safe Base64-encoded URL of the blind watermark image
std::string image = "http://" + bucket_name + ".cos.ap-guangzhou.myqcloud.com/" + object_name + "_watermark";
// Blind watermark processing parameter
rule.rule = "watermark/3/type/1/image/" + CodecUtil::Base64Encode(image);
pic_operation.AddRule(rule);

CosResult result = cos.PutImage(req, &resp);
if (result.IsSucc()) {
// The call is successful. You can call the `resp` member functions to get the return content.
} else {
// The call failed. You can call the `result` member functions to get the error information.
}

Parameter description

Parameter
Description
Type
Required
req
PutImage operation request.
PutImageByFileReq
Yes
resp
PutImage operation response.
PutImageByFileResp
Yes

Adding Blind Watermark During Download

Feature description

This API is used to add a blind watermark when downloading images.

Method prototype

CosResult GetObject(const GetObjectByFileReq& request, GetObjectByFileResp* response);

Sample request

qcloud_cos::CosConfig config("./config.json");
qcloud_cos::CosAPI cos(config);
std::string bucket_name = "examplebucket-1250000000";

GetObjectByFileReq req(bucket_name, object_name, local_file);
GetObjectByFileResp resp;

// Blind watermark text
std::string watermark_text = "test";
// URL-safe Base64-encoded blind watermark parameter
std::string watermark_param = "watermark/3/type/3/text/" + CodecUtil::Base64Encode(watermark_text);
req.AddParam(watermark_param, "");

CosResult result = cos.GetObject(req, &resp);
if (result.IsSucc()) {
// The call is successful. You can call the `resp` member functions to get the return content.
} else {
// The call failed. You can call the `result` member functions to get the error information.
}

Parameter description

Parameter
Description
Type
Required
req
PutImage operation request.
PutImageByFileReq
Yes
resp
PutImage operation response.
PutImageByFileResp
Yes
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon