简介
本文档提供关于盲水印的 API 概览以及 SDK 示例代码。
API | 操作描述 |
对本地图片添加或提取盲水印并上传至存储桶 |
SDK API 参考
添加盲水印
功能说明
盲水印支持在上传时添加以及下载时添加。
示例代码一:上传时添加盲水印
List<PicOperationRule> rules = new LinkedList<>();// 添加一条将盲水印 rule,处理后的图片在存储桶中的位置标识符为// examplewatermarkobjectrules.add(new PicOperationRule("examplewatermarkobject","watermark/3/type/1/image/aHR0cDovL2V4YW1wbGVzLTEyNTEwMDAw"));PicOperations picOperations = new PicOperations(true, rules);PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, cosPath, srcPath);putObjectRequest.setPicOperations(picOperations);// 上传成功后,您将会得到 2 张图片,分别是原始图片和处理后图片COSXMLUploadTask cosxmlUploadTask = transferManager.upload(putObjectRequest, uploadId);
说明
示例代码二:下载时添加盲水印
GetObjectRequest getObjectRequest = new GetObjectRequest(bucket, cosPath, savePathDir, savedFileName);// 添加文字盲水印getObjectRequest.addQuery("watermark/3/type/3/text/dGVuY2VudCBjbG91ZA==", null);COSXMLDownloadTask cosxmlDownloadTask =transferManager.download(applicationContext, getObjectRequest);
说明