ImageViewTemplate.php
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
namespace Qcloud\Cos\ImageParamTemplate;
/**
* Parses default XML exception responses
*/
class ImageViewTemplate extends ImageTemplate
{
private $mode;
private $width;
private $height;
private $format;
private $quality;
private $ignoreError;
public function __construct() {
parent::__construct();
$this->mode = "";
$this->width = "";
$this->height = "";
$this->format = "";
$this->quality = "";
$this->ignoreError = "";
}
public function setMode($value) {
$this->mode = "/" . $value;
}
public function setWidth($value) {
$this->width = "/w/" . $value;
}
public function setHeight($value) {
$this->height = "/h/" . $value;
}
public function setFormat($value) {
$this->format = "/format/" . $value;
}
public function setQuality($qualityType, $qualityValue, $force = 0) {
if($qualityType == 1){
$this->quality = "/q/$qualityValue" ;
if($force){
$this->quality .= "!";
}
}else if($qualityType == 2){
$this->quality = "/rq/$qualityValue" ;
}else if ($qualityType == 3){
$this->quality = "/lq/$qualityValue" ;
}
}
public function ignoreError() {
$this->ignoreError = '/ignore-error/1';
}
public function getMode() {
return $this->mode;
}
public function getWidth() {
return $this->width;
}
public function getHeight() {
return $this->height;
}
public function getFormat() {
return $this->format;
}
public function getQuality() {
return $this->quality;
}
public function queryString() {
$head = "imageView2";
$res = "";
if($this->mode) {
$res .= $this->mode;
}
if($this->width) {
$res .= $this->width;
}
if($this->height) {
$res .= $this->height;
}
if($this->format) {
$res .= $this->format;
}
if($this->quality) {
$res .= $this->quality;
}
if($this->ignoreError) {
$res .= $this->ignoreError;
}
if($res) {
$res = $head . $res;
}
return $res;
}
public function resetRule() {
$this->mode = "";
$this->width = "";
$this->height = "";
$this->format = "";
$this->quality = "";
}
}