Updated on 2024-08-09 GMT+08:00

Image Watermarks

You can pre-process an image watermark before adding it to an image.

The pre-processing operations include those described in Resizing Images, Rotating Images, and Cropping Images, but cropping an image watermark into an inscribed circle is not allowed. When resizing an image watermark, you can scale it to a specific percentage of the original image size.

Table 1 describes the image watermark parameters.

Table 1 Image watermark parameters

Parameter

Value Description

Code Example

image

Mandatory. It indicates the watermark image path.

The watermark image path is bucketName/objectName (encoding required) or bucketName/objectName?x-image-process=image/command (encoding required).

NOTICE:

The content must be URL-safe Base64 encoded in the encodedObject = url_safe_base64_encode(object) format. For example, object panda.png will be encoded as cGFuZGEucG5n.

image/resize,w_400/watermark,image_aW1h

Z2UtZGVtby9sb2dvLnBuZz94LWltYWdlLXByb

2Nlc3M9aW1hZ2UvcmVzaXplLFBfMzA=,t_90,

g_br,x_10,y_10

P

It indicates the percentage of the original image the image watermark will be scaled to. The value ranges from 1 to 100.

NOTICE:

P used here for resizing is case-sensitive. To adjust the size of an image watermark, see Resizing Images (except the p parameter).

image-demo/logo.png?x-image-process=image/resize,P_50

Examples of Making API Calls

Example of Using GUI

To add an image watermark to an image, you can create a watermark style on OBS Console and then apply it to the image. The following gives an example of creating a watermark style on OBS Console:

  1. Log in to OBS Console and click the required bucket name. In the navigation pane, choose Data Processing > Image Processing.
  2. Click Create to go to the style editing page
  3. On the editing page, specify a style name, choose GUI for Edit Mode, and click Watermark.

    A style name consists of letters (uppercase or lowercase), digits, periods (.), underscores (_), and hyphens (-) and contains 1 to 256 characters, for example, rotate_0001.

  4. Configure the following watermark parameters. For details, see Figure 4.

    • Watermark Type: Choose Image watermark.
    • Watermark Image Path: Enter e-share/image-demo/logo.png.
    • Image Size (%): Set this parameter based on whether the watermark image is zoomed out.
    • Brightness: Retain the default value 0.
    • Contrast: Retain the default value 0.
    • Transparency: Set this parameter to 90.
    • Watermark Position: Select the arrow at the bottom right, as shown in .
    • Vertical Margin: Retain the default value 10.
    • Horizontal Margin: Retain the default value 10.
    Figure 4 Configuring an image watermark

  5. Click OK to save the style. The new style will be displayed in the style list.

    You can use the new watermark style to process images by referring to Using the Image Style.