123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- require dirname(__FILE__, 2) . '/vendor/autoload.php';
- $secretId = "SECRETID";
- $secretKey = "SECRETKEY";
- $region = "ap-beijing";
- $cosClient = new Qcloud\Cos\Client(
- array(
- 'region' => $region,
- 'scheme' => 'https',
- 'credentials'=> array(
- 'secretId' => $secretId,
- 'secretKey' => $secretKey)));
- try {
- $blindWatermarkTemplate = new Qcloud\Cos\ImageParamTemplate\BlindWatermarkTemplate();
- $blindWatermarkTemplate->setImage("http://examplebucket-125000000.cos.ap-beijing.myqcloud.com/shuiyin.jpeg");
- $blindWatermarkTemplate->setType(2);
- $blindWatermarkTemplate->setLevel(3);
- $blindWatermarkTemplate->setVersion("2.0");
-
- $result = $cosClient->getObject(array(
- 'Bucket' => 'examplebucket-125000000',
- 'Key' => 'exampleobject',
- 'ImageHandleParam' => $blindWatermarkTemplate->queryString(),
- 'SaveAs' => '/data/exampleobject'
- ));
-
- print_r($result);
-
-
- $local_path = "/data/exampleobject";
- $picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
- $picOperationsTemplate->setIsPicInfo(1);
- $picOperationsTemplate->addRule($blindWatermarkTemplate, "resultobject");
- $result = $cosClient->putObject(array(
- 'Bucket' => 'examplebucket-125000000',
- 'Key' => 'exampleobject',
- 'Body' => fopen($local_path, 'rb'),
- 'PicOperations' => $picOperationsTemplate->queryString(),
- ));
-
- print_r($result);
-
-
- $result = $cosClient->ImageProcess(array(
- 'Bucket' => 'examplebucket-125000000',
- 'Key' => 'exampleobject',
- 'PicOperations' => $picOperationsTemplate->queryString(),
- ));
-
- print_r($result);
-
- } catch (\Exception $e) {
-
- echo($e);
- }
|