1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* This file is part of the O2System Framework package.
|
4
|
|
|
*
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE
|
6
|
|
|
* file that was distributed with this source code.
|
7
|
|
|
*
|
8
|
|
|
* @author Steeve Andrian Salim
|
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim
|
10
|
|
|
*/
|
11
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------
|
13
|
|
|
|
14
|
|
|
namespace O2System\Image\Abstracts;
|
15
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------
|
17
|
|
|
|
18
|
|
|
use O2System\Image\Dimension\Axis;
|
19
|
|
|
|
20
|
|
|
/**
|
21
|
|
|
* Class AbstractWatermark
|
22
|
|
|
*
|
23
|
|
|
* @package O2System\Image\Abstracts
|
24
|
|
|
*/
|
25
|
|
|
abstract class AbstractWatermark
|
26
|
|
|
{
|
27
|
|
|
/**
|
28
|
|
|
* AbstractWatermark::$position
|
29
|
|
|
*
|
30
|
|
|
* Watermark position.
|
31
|
|
|
*
|
32
|
|
|
* @var string
|
33
|
|
|
*/
|
34
|
|
|
protected $position = 'AUTO';
|
35
|
|
|
|
36
|
|
|
/**
|
37
|
|
|
* AbstractWatermark::$axis
|
38
|
|
|
*
|
39
|
|
|
* Watermark axis.
|
40
|
|
|
*
|
41
|
|
|
* @var Axis
|
42
|
|
|
*/
|
43
|
|
|
protected $axis;
|
44
|
|
|
|
45
|
|
|
/**
|
46
|
|
|
* AbstractWatermark::$padding
|
47
|
|
|
*
|
48
|
|
|
* Watermark padding.
|
49
|
|
|
*
|
50
|
|
|
* @var int
|
51
|
|
|
*/
|
52
|
|
|
protected $padding = 25;
|
53
|
|
|
|
54
|
|
|
// ------------------------------------------------------------------------
|
55
|
|
|
|
56
|
|
|
/**
|
57
|
|
|
* AbstractWatermark::getPosition
|
58
|
|
|
*
|
59
|
|
|
* Gets watermark position.
|
60
|
|
|
*
|
61
|
|
|
* @return string
|
62
|
|
|
*/
|
63
|
|
|
public function getPosition()
|
64
|
|
|
{
|
65
|
|
|
return $this->position;
|
66
|
|
|
}
|
67
|
|
|
|
68
|
|
|
// ------------------------------------------------------------------------
|
69
|
|
|
|
70
|
|
|
/**
|
71
|
|
|
* AbstractWatermark::setPosition
|
72
|
|
|
*
|
73
|
|
|
* Sets watermark position.
|
74
|
|
|
*
|
75
|
|
|
* @param string $position
|
76
|
|
|
*
|
77
|
|
|
* @return static
|
78
|
|
|
*/
|
79
|
|
|
public function setPosition($position)
|
80
|
|
|
{
|
81
|
|
|
if (in_array($position, [
|
82
|
|
|
'CENTER',
|
83
|
|
|
'MIDDLE',
|
84
|
|
|
'MIDDLE_MIDDLE',
|
85
|
|
|
'MIDDLE_LEFT',
|
86
|
|
|
'MIDDLE_RIGHT',
|
87
|
|
|
'MIDDLE_TOP',
|
88
|
|
|
'MIDDLE_BOTTOM',
|
89
|
|
|
'TOP_LEFT',
|
90
|
|
|
'TOP_RIGHT',
|
91
|
|
|
'BOTTOM_LEFT',
|
92
|
|
|
'BOTTOM_RIGHT',
|
93
|
|
|
])) {
|
94
|
|
|
$this->position = strtoupper($position);
|
95
|
|
|
}
|
96
|
|
|
|
97
|
|
|
return $this;
|
98
|
|
|
}
|
99
|
|
|
|
100
|
|
|
// ------------------------------------------------------------------------
|
101
|
|
|
|
102
|
|
|
/**
|
103
|
|
|
* AbstractWatermark::getAxis
|
104
|
|
|
*
|
105
|
|
|
* Gets watermark axis.
|
106
|
|
|
*
|
107
|
|
|
* @return bool|\O2System\Image\Dimension\Axis
|
108
|
|
|
*/
|
109
|
|
|
public function getAxis()
|
110
|
|
|
{
|
111
|
|
|
if ($this->axis instanceof Axis) {
|
|
|
|
|
112
|
|
|
return $this->axis;
|
113
|
|
|
}
|
114
|
|
|
|
115
|
|
|
return false;
|
116
|
|
|
}
|
117
|
|
|
|
118
|
|
|
// ------------------------------------------------------------------------
|
119
|
|
|
|
120
|
|
|
/**
|
121
|
|
|
* AbstractWatermark::setAxis
|
122
|
|
|
*
|
123
|
|
|
* Sets watermark axis.
|
124
|
|
|
*
|
125
|
|
|
* @param Axis $axis
|
126
|
|
|
*
|
127
|
|
|
* @return static
|
128
|
|
|
*/
|
129
|
|
|
public function setAxis(Axis $axis)
|
130
|
|
|
{
|
131
|
|
|
$this->axis = $axis;
|
132
|
|
|
|
133
|
|
|
return $this;
|
134
|
|
|
}
|
135
|
|
|
|
136
|
|
|
// ------------------------------------------------------------------------
|
137
|
|
|
|
138
|
|
|
/**
|
139
|
|
|
* AbstractWatermark::getPadding
|
140
|
|
|
*
|
141
|
|
|
* Gets watermark padding.
|
142
|
|
|
*
|
143
|
|
|
* @return int
|
144
|
|
|
*/
|
145
|
|
|
public function getPadding()
|
146
|
|
|
{
|
147
|
|
|
return $this->padding;
|
148
|
|
|
}
|
149
|
|
|
|
150
|
|
|
// ------------------------------------------------------------------------
|
151
|
|
|
|
152
|
|
|
/**
|
153
|
|
|
* AbstractWatermark::setPadding
|
154
|
|
|
*
|
155
|
|
|
* Sets watermark padding.
|
156
|
|
|
*
|
157
|
|
|
* @param int $padding
|
158
|
|
|
*
|
159
|
|
|
* @return static
|
160
|
|
|
*/
|
161
|
|
|
public function setPadding($padding)
|
162
|
|
|
{
|
163
|
|
|
$this->padding = (int)$padding;
|
164
|
|
|
|
165
|
|
|
return $this;
|
166
|
|
|
}
|
167
|
|
|
} |