Text Watermarks
You can configure the size, font, and color for text images. Table 1 describes the parameters.
Parameter |
Value Description |
Code Example |
---|---|---|
text |
Mandatory for adding text watermarks
NOTICE:
The content must be URL-safe Base64 encoded in the encodeText = url_safe_base64_encode(fontText) format, with a maximum of 64 characters (16 full-width characters at most). |
image/watermark,text_SGVsbG8g5Zu- 54mH5pyN5YqhIQ,size_60,color_FF0000,type_ ZmFuZ3poZW5nc2h1c29uZw==,g_center,rotate_30 |
size |
Optional. It represents the size of a text watermark, ranging from 0 (exclusive) to 1000 (inclusive). The default value is 40. |
|
type |
Optional. It represents the font of a text watermark. Available values are those shown in Table 2. The default value is wqy-zenhei (d3F5LXplbmhlaQ after encoding).
NOTICE:
- The content must be URL-safe Base64 encoded in the encodeText = url_safe_base64_encode(fontType) format. - Line breaks are currently not supported. |
|
color |
Optional. It represents the color of a text watermark. The value is a six-digit hexadecimal code, from 000000 (default value, representing black) to FFFFFF. |
|
shadow |
Optional. It represents the transparency of a text watermark. The value ranges from 0 (exclusive) to 100 (inclusive). |
|
fill |
Optional. It represents the filling effect of a text watermark. The value can be 0 or 1.
|
|
rotate |
Optional. It represents the clockwise rotation angle of a text watermark. The value ranges from 0 (exclusive) to 360 (exclusive). |
Parameter |
Value After URL-Safe Base64 Encoding |
Value Description |
Remarks |
---|---|---|---|
droidsansfallback |
ZHJvaWRzYW5zZmFsbGJhY2s= |
DroidSansFallback |
According to Request for Comments (RFC), the fuller "=" can be omitted, and the value becomes ZHJvaWRzYW5zZmFsbGJhY2s. |
fangzhengfangsong |
ZmFuZ3poZW5nZmFuZ3Nvbmc= |
FZFongSong |
According to RFC, the fuller "=" can be omitted, and the value becomes ZmFuZ3poZW5nZmFuZ3Nvbmc. |
fangzhengheiti |
ZmFuZ3poZW5naGVpdGk= |
FZSimHei |
According to RFC, the fuller "=" can be omitted, and the value becomes ZmFuZ3poZW5naGVpdGk. |
fangzhengkaiti |
ZmFuZ3poZW5na2FpdGk= |
FZKaiTi |
According to RFC, the fuller "=" can be omitted, and the value becomes ZmFuZ3poZW5na2FpdGk. |
fangzhengshusong |
ZmFuZ3poZW5nc2h1c29uZw== |
FZShuSong |
According to RFC, the fuller "=" can be omitted, and the value becomes ZmFuZ3poZW5nc2h1c29uZw. |
wqy-microhei |
d3F5LW1pY3JvaGVp |
WenQuanYi Micro Hei |
- |
wqy-zenhei |
d3F5LXplbmhlaQ== |
WenQuanYi Zen Hei |
According to RFC, the fuller "=" can be omitted, and the value becomes d3F5LXplbmhlaQ. |
Examples of Making API Calls
- Add the text watermark Hello to an image, with the text size set to 60, color to red, and font to FZShuSong.
Relevant parameters:
Safe Base64 code: SGVsbG8g5Zu, namely text_SGVsbG8g5Zu
Text size: size_60
Text color: color_FF0000
Text font: type_ZmFuZ3poZW5nc2h1c29uZw==
Request URL:
- Clockwise rotate a text watermark through an angle of 30 degrees and add it to the center of an image. Keep other parameters the same as those in the previous example.
https://hw-image-demo.obs.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=image/watermark,text_SGVsbG8g5Zu,size_60,color_FF0000,type_ZmFuZ3poZW5nc2h1c29uZw==,g_center,rotate_30
- Add image and text watermarks at the same time. Add text watermark Hello at the bottom right, with the size set to 60, shadow to 50, and color to red.
Add image watermark logo.png, with both horizontal and vertical margins set to 10.
Set the transparency of both text and image watermarks to 50 and put the image watermark in front and the text watermark behind, in the bottom alignment.
- Add an image watermark first and then a text watermark. Add text watermark Hello at the bottom right, with the size set to 60 and color to red.
Add image watermark logo.png, with a horizontal margin of 40 and a vertical margin of 10.
Set the transparency of the image watermark to 90.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot