-
Notifications
You must be signed in to change notification settings - Fork 0
/
I.php
92 lines (83 loc) · 2.37 KB
/
I.php
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
<?php
namespace TFC\Image;
use Google\ApiCore\ApiException as AE;
use Google\Cloud\Vision\V1\AnnotateImageResponse as Res;
use Google\Cloud\Vision\V1\ImageAnnotatorClient as Annotator;
use Google\Protobuf\Internal\RepeatedField;
# 2020-11-10
final class I {
/**
* 2020-11-10
* @used-by \TFC\Image\Command\C2::p()
*/
function __construct(string $p) {$this->_path = $p;}
/**
* 2020-11-10
* @used-by \TFC\Image\Command\C2::p()
* @throws AE
*/
function annotationsObject():RepeatedField {return dfc($this, function():RepeatedField {
$a = new Annotator; /** @var Annotator $a */
try {$resO = $a->objectLocalization($this->f()); /** @var Res $resO */}
finally {$a->close();}
return $resO->getLocalizedObjectAnnotations();
});}
/**
* 2020-11-10 https://cloud.google.com/vision/docs/ocr
* @used-by \TFC\Image\Command\C2::p()
* @throws AE
*/
function annotationsText():RepeatedField {return dfc($this, function():RepeatedField {
$a = new Annotator; /** @var Annotator $a */
try {$resT = $a->textDetection($this->f()); /** @var Res $resT */}
finally {$a->close();}
return $resT->getTextAnnotations();
});}
/**
* 2020-11-10
* @used-by \TFC\Image\Command\C2::p()
*/
function basename():string {return basename($this->_path);}
/**
* 2020-11-10
* 2022-12-07
* It will return @see \GDImage in PHP ≥ 8:
* https://www.php.net/manual/function.imagecreatefromjpeg.php#refsect1-function.imagecreatefromjpeg-changelog
* @used-by \TFC\Image\Command\C2::p()
* @return resource
*/
function createResource() {return imagecreatefromjpeg($this->_path);}
/**
* 2020-11-10
* @used-by \TFC\Image\Command\C2::p()
*/
function h():int {return $this->size()[1];}
/**
* 2020-11-10
* @used-by \TFC\Image\Command\C2::p()
*/
function w():int {return $this->size()[0];}
/**
* 2020-11-10
* @used-by self::annotationsObject()
* @used-by self::annotationsText()
*/
private function f():string {return dfc($this, function() {return file_get_contents($this->_path);});}
/**
* 2020-11-10
* @used-by self::h()
* @used-by self::w()
* @return int[]
*/
private function size():array {return dfc($this, function() {return getimagesize($this->_path);});}
/**
* 2020-11-10
* @used-by self::__construct()
* @used-by self::basename()
* @used-by self::createResource()
* @used-by self::f()
* @used-by self::size()
* @var string
*/
private $_path;
}