|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Goose\Images; |
|
4
|
|
|
|
|
5
|
|
|
use DOMWrap\Element; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Image |
|
9
|
|
|
* |
|
10
|
|
|
* @package Goose\Images |
|
11
|
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 |
|
12
|
|
|
*/ |
|
13
|
|
|
class Image { |
|
14
|
|
|
/** |
|
15
|
|
|
* @param mixed[] $options |
|
16
|
|
|
*/ |
|
17
|
|
|
public function __construct($options = []) { |
|
18
|
|
|
foreach ($options as $key => $value) { |
|
19
|
|
|
$method = 'set' . ucfirst($key); |
|
20
|
|
|
|
|
21
|
|
|
if (method_exists($this, $method)) { |
|
22
|
|
|
call_user_func([$this, $method], $value); |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** @var Element */ |
|
28
|
|
|
private $topImageNode = null; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param Element $topImageNode |
|
32
|
|
|
* |
|
33
|
|
|
* @return self |
|
34
|
|
|
*/ |
|
35
|
|
|
public function setTopImageNode(Element $topImageNode): self { |
|
36
|
|
|
$this->topImageNode = $topImageNode; |
|
37
|
|
|
|
|
38
|
|
|
return $this; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return Element |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getTopImageNode(): Element { |
|
45
|
|
|
return $this->topImageNode; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** @var string */ |
|
49
|
|
|
private $imageSrc = ''; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param string $imageSrc |
|
53
|
|
|
* |
|
54
|
|
|
* @return self |
|
55
|
|
|
*/ |
|
56
|
|
|
public function setImageSrc(string $imageSrc): self { |
|
57
|
|
|
$this->imageSrc = $imageSrc; |
|
58
|
|
|
|
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getImageSrc(): string { |
|
66
|
|
|
return $this->imageSrc; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** @var float */ |
|
70
|
|
|
private $imageScore = 0.0; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param float $imageScore |
|
74
|
|
|
* |
|
75
|
|
|
* @return self |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setImageScore(float $imageScore): self { |
|
78
|
|
|
$this->imageScore = $imageScore; |
|
79
|
|
|
|
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return float |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getImageScore(): float { |
|
87
|
|
|
return $this->imageScore; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** @var float */ |
|
91
|
|
|
private $confidenceScore = 0.0; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param float $confidenceScore |
|
95
|
|
|
* |
|
96
|
|
|
* @return self |
|
97
|
|
|
*/ |
|
98
|
|
|
public function setConfidenceScore(float $confidenceScore): self { |
|
99
|
|
|
$this->confidenceScore = $confidenceScore; |
|
100
|
|
|
|
|
101
|
|
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @return float |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getConfidenceScore(): float { |
|
108
|
|
|
return $this->confidenceScore; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** @var int */ |
|
112
|
|
|
private $height = 0; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param int $height |
|
116
|
|
|
* |
|
117
|
|
|
* @return self |
|
118
|
|
|
*/ |
|
119
|
|
|
public function setHeight(int $height): self { |
|
120
|
|
|
$this->height = $height; |
|
121
|
|
|
|
|
122
|
|
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return int |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getHeight(): int { |
|
129
|
|
|
return $this->height; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** @var int */ |
|
133
|
|
|
private $width = 0; |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @param int $width |
|
137
|
|
|
* |
|
138
|
|
|
* @return self |
|
139
|
|
|
*/ |
|
140
|
|
|
public function setWidth(int $width): self { |
|
141
|
|
|
$this->width = $width; |
|
142
|
|
|
|
|
143
|
|
|
return $this; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @return int |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getWidth(): int { |
|
150
|
|
|
return $this->width; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** @var string */ |
|
154
|
|
|
private $imageExtractionType = 'NA'; |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @param string $imageExtractionType |
|
158
|
|
|
* |
|
159
|
|
|
* @return self |
|
160
|
|
|
*/ |
|
161
|
|
|
public function setImageExtractionType(string $imageExtractionType): self { |
|
162
|
|
|
$this->imageExtractionType = $imageExtractionType; |
|
163
|
|
|
|
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @return string |
|
169
|
|
|
*/ |
|
170
|
|
|
public function getImageExtractionType(): string { |
|
171
|
|
|
return $this->imageExtractionType; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** @var int */ |
|
175
|
|
|
private $bytes = 0; |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @param int $bytes |
|
179
|
|
|
* |
|
180
|
|
|
* @return self |
|
181
|
|
|
*/ |
|
182
|
|
|
public function setBytes(int $bytes): self { |
|
183
|
|
|
$this->bytes = $bytes; |
|
184
|
|
|
|
|
185
|
|
|
return $this; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* @return int |
|
190
|
|
|
*/ |
|
191
|
|
|
public function getBytes(): int { |
|
192
|
|
|
return $this->bytes; |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
|