tencent cloud

文档反馈

盲水印

最后更新时间:2024-01-05 14:14:08

    简介

    本文档提供关于盲水印相关的 API 概览以及 SDK 示例代码。

    添加盲水印

    功能说明

    盲水印支持在上传时添加以及下载时添加。

    示例代码一:上传时添加盲水印

    PutObjectRequest request = new PutObjectRequest(bucket, key, srcPath);
    
    JObject o = new JObject();
    // 不返回原图
    o["is_pic_info"] = 0;
    JArray rules = new JArray();
    JObject rule = new JObject();
    rule["bucket"] = bucket;
    rule["fileid"] = key;
    //处理参数,规则参见:https://www.tencentcloud.com/document/product/436/46782?from_cn_redirect=1
    rule["rule"] = "watermark/3/type/<type>/image/<imageUrl>/text/<text>/level/<level>";
    rules.Add(rule);
    o["rules"] = rules;
    
    string ruleString = o.ToString(Formatting.None);
    request.SetRequestHeader("Pic-Operations", ruleString);
    //执行请求
    PutObjectResult result = cosXml.PutObject(request);
    说明
    更多完整示例,请前往 GitHub 查看。

    示例代码二:下载时添加盲水印

    GetObjectRequest getObjectRequest = new GetObjectRequest(bucket, key, localDir, localFileName);
    //处理参数,规则参见:https://www.tencentcloud.com/document/product/436/46782?from_cn_redirect=1
    getObjectRequest.SetQueryParameter("watermark/3/type/<type>/image/<imageUrl>/text/<text>", null);
    
    GetObjectResult result = cosXml.GetObject(getObjectRequest);
    说明
    更多完整示例,请前往 GitHub 查看。
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持