Help Center/ Data Security Center/ API Reference (ME-Abu Dhabi Region)/ API Description/ Image Watermarking/ Injecting Invisible Watermarks into Images (Image Addresses)
Updated on 2022-12-29 GMT+08:00

Injecting Invisible Watermarks into Images (Image Addresses)

Function

This API is used to inject invisible text watermarks or invisible image watermarks into an image whose storage address is specified (only a cloud service OBS path is supported). DSC returns the injected watermark in a specified storage location (an OBS path). The supported image formats include .jpg, .jpeg, .jpe, .png, .bmp, .dib, .rle, .tiff, .tif, .ppm, .webp, .tga, .tpic, and .gif.

URI

POST /v1/{project_id}/image-address/watermark/embed

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

region_id

Yes

String

ID of the region where the current project is located, for example, xx-xx-1.

src_file

Yes

String

Address of the image to be watermarked. Currently, only cloud service OBS files are supported. The format is obs://bucket/object, where bucket indicates the name of the OBS bucket in the same region as the current project, and object indicates the full path name of the object. For example, obs://hwbucket/hwinfo/hw.png.

blind_watermark

No

String

Content of the invisible text watermark, which cannot exceed 32 characters. Currently, only digits and uppercase and lowercase letters are supported. Either this parameter or image_watermark must be set.

image_watermark

No

String

Address of the invisible image watermark. Its format requirements are the same as those of src_file. Either image_watermark or blind_watermark must be set. If both are set, only image_watermark takes effect.

dst_file

No

String

Storage address of the watermarked image. The format and requirements are the same as those of the src_file field. If this field is not set, the value of src_file is used by default, that is, the original file is overwritten after the watermark is added.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

region_id

String

ID of the region where the current project is located, for example, xx-xx-1.

watermarked_file

String

Address of the watermarked image on OBS. Currently, only cloud service OBS files are supported. The format is obs://bucket/object, where bucket indicates the name of the OBS bucket in the same region as the current project, and object indicates the full path name of the object. For example, obs://hwbucket/hwinfo/hw.png.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error Code

error_msg

String

Error Message

Example Requests

POST /v1/{project_id}/image-address/watermark/embed HTTP/1.1

{
  "region_id" : "xx-xx-1",
  "src_file" : "obs://hwbucket/test.png",
  "blind_watermark" : "testWaterMark"
}

Example Responses

Status code: 200

Request succeeded.

{
  "region_id" : "xx-xx-1",
  "watermarked_file" : "obs://hwbucket/test.png"
}

Status code: 400

Invalid request

{
  "error_code" : "DSC.00000007",
  "error_msg" : "File format error"
}

Status Codes

Status Code

Description

200

Request succeeded.

400

Invalid request

Error Codes

See Error Codes.