12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?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 {
-
- $imageViewRule = new Qcloud\Cos\ImageParamTemplate\ImageViewTemplate();
- $imageViewRule->setMode(1);
- $imageViewRule->setWidth(400);
- $imageViewRule->setHeight(600);
- $imageViewRule->setFormat('jpg');
- $imageViewRule->setQuality(1, 85);
- $imageViewRule->ignoreError();
- $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
- $picOperations->setIsPicInfo(1);
- $picOperations->addRule($imageViewRule, "output.png");
-
- $downloadUrl = 'https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/xxx.jpg';
- $rule = $imageViewRule->queryString();
- echo "{$downloadUrl}?{$rule}";
-
-
- $result = $cosClient->putObject(array(
- 'Bucket' => 'examplebucket-125000000',
- 'Key' => 'object.jpg',
- 'Body' => fopen('/tmp/local.jpg', 'rb'),
- 'PicOperations' => $picOperations->queryString(),
- ));
-
- print_r($result);
-
-
- $result = $cosClient->ImageProcess(array(
- 'Bucket' => 'examplebucket-1250000000',
- 'Key' => 'test.png',
- 'PicOperations' => $picOperations->queryString(),
- ));
-
- print_r($result);
-
- } catch (\Exception $e) {
-
- echo($e);
- }
|