Text Watermarks

Last updated: 2021-03-24 15:20:49

    Feature

    This API is used to provide real-time text watermarking in Tencent Cloud CI. The size of the input image to be processed cannot exceed 20 MB, its width and height cannot exceed 30,000 pixels respectively, and its total pixels cannot exceed 250 million. The width and height of the output image cannot exceed 9,999 pixels respectively. For animated images, the input image's Width x Height x Number of frames cannot exceed 250 million pixels.

    API Form

    download_url?watermark/2/text/<encodedText>
                            /font/<encodedFont>
                            /fontsize/<fontSize>
                            /fill/<encodedColor>
                            /dissolve/<dissolve>
                            /gravity/<gravity>
                            /dx/<dx>
                            /dy/<dy>
                            /batch/<type>
                            /degree/<degree>
    

    Note:

    Please ignore the preceding spaces and line breaks.

    Parameter Description

    Operation name: watermark. The number 2 indicates the watermark type is text watermark.

    Parameter Description
    download_url URL that is used to access a file. The URL form is <BucketName-APPID>.cos.<picture region>.<domain>.com/<picture name>,
    for example, examplebucket-1250000000.cos.ap-shanghai.myqcloud.com/picture.jpeg.
    /text/ Watermark content, which is encoded with Base64 that is safe to the URL.
    /font/ Watermark font, which is encoded with Base64 that is safe to the URL. The default value is tahoma.ttf.
    /fontsize/ Watermark text fontsize in pounds. The default value is 13.
    /fill/ Watermark font color, which must be set to the hexadecimal RGB format (such as #FF0000). The default value is gray. For more information, see RGB Code Table. The value must be encoded with Base64 that is safe to the URL. The default value is #3D3D3D.
    /dissolve/ Text transparency. Value range: 1-100. The default value is 90 (90% non-transparent).
    /gravity/ Text watermark position, which is a 3x3 grid position (See the 3x3 grid position diagram). The default value is SouthEast.
    /dx/ Horizontal margin in pixels. The default value is 0.
    /dy/ Vertical margin in pixels. The default value is 0.
    /batch/ Tiled watermarking, which can tile the text watermark to the entire image. If you set batch to 1, tiled watermarking is enabled.
    /degree/ Rotation angle of the text watermark. Value range: 0 - 360. The default value is 0.

    3x3 Grid Position Diagram

    A 3x3 grid position diagram provides position reference for multiple image operations. Red dots show the origin points of each region. After you use the gravity parameter to select a region, displacement must be based on the corresponding origin point.

    Note:

    • When the gravity parameter is set to center, the dx and dy parameters are invalid.
    • When the gravity parameter is set to north or south, the dx parameter is invalid, and the watermark is centered horizontally.
    • When the gravity parameter is set to west or east, the dy parameter is invalid, and the watermark is centered vertically.

    Example

    This example shows you how to add a text watermark.

    http://examples-1251000004.cos.ap-shanghai.myqcloud.com/sample.jpeg?watermark/2/text/6IW-6K6v5LqRwrfkuIfosaHkvJjlm74/fill/IzNEM0QzRA/fontsize/20/dissolve/50/gravity/northeast/dx/20/dy/20/batch/1/degree/45
    

    After the text watermark is added, the effect is as follows:

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help