ImageWatermarkTemplate.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace Qcloud\Cos\ImageParamTemplate;
  3. class ImageWatermarkTemplate extends ImageTemplate
  4. {
  5. private $image;
  6. private $gravity;
  7. private $dx;
  8. private $dy;
  9. private $blogo;
  10. private $scatype;
  11. private $spcent;
  12. public function __construct() {
  13. parent::__construct();
  14. $this->image = "";
  15. $this->gravity = "";
  16. $this->dx = "";
  17. $this->dy = "";
  18. $this->blogo = "";
  19. $this->scatype = "";
  20. $this->spcent = "";
  21. }
  22. public function setImage($value) {
  23. $this->image = "/image/" . $this->ciBase64($value);
  24. }
  25. public function setGravity($value) {
  26. $this->gravity = "/gravity/" . $value;
  27. }
  28. public function setDx($value) {
  29. $this->dx = "/dx/" . $value;
  30. }
  31. public function setDy($value) {
  32. $this->dy = "/dy/" . $value;
  33. }
  34. public function setBlogo($value) {
  35. $this->blogo = "/blogo/" . $value;
  36. }
  37. public function setScatype($value) {
  38. $this->scatype = "/scatype/" . $value;
  39. }
  40. public function setSpcent($value) {
  41. $this->spcent = "/spcent/" . $value;
  42. }
  43. public function getImage() {
  44. return $this->image;
  45. }
  46. public function getGravity() {
  47. return $this->gravity;
  48. }
  49. public function getDx() {
  50. return $this->dx;
  51. }
  52. public function getDy() {
  53. return $this->dy;
  54. }
  55. public function getBlogo() {
  56. return $this->blogo;
  57. }
  58. public function getScatype() {
  59. return $this->scatype;
  60. }
  61. public function getSpcent() {
  62. return $this->spcent;
  63. }
  64. public function queryString() {
  65. $head = "watermark/1";
  66. $res = "";
  67. if($this->image) {
  68. $res .= $this->image;
  69. }
  70. if($this->gravity) {
  71. $res .= $this->gravity;
  72. }
  73. if($this->dx) {
  74. $res .= $this->dx;
  75. }
  76. if($this->dy) {
  77. $res .= $this->dy;
  78. }
  79. if($this->blogo) {
  80. $res .= $this->blogo;
  81. }
  82. if($this->scatype) {
  83. $res .= $this->scatype;
  84. }
  85. if($this->spcent) {
  86. $res .= $this->spcent;
  87. }
  88. if($res) {
  89. $res = $head . $res;
  90. }
  91. return $res;
  92. }
  93. public function resetRule() {
  94. $this->image = "";
  95. $this->gravity = "";
  96. $this->dx = "";
  97. $this->dy = "";
  98. $this->blogo = "";
  99. $this->scatype = "";
  100. $this->spcent = "";
  101. }
  102. }