File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change 48
48
49
49
final class QrReader
50
50
{
51
+ const SOURCE_TYPE_FILE = 'file ' ;
52
+ const SOURCE_TYPE_BLOB = 'blob ' ;
51
53
public $ result ;
52
54
53
- function __construct ($ filename )
55
+ function __construct ($ imgsource , $ sourcetype = ' file ' )
54
56
{
55
57
56
58
try {
59
+ switch ($ sourcetype ) {
60
+ case 'file ' :
61
+ if (extension_loaded ('imagick ' )) {
62
+ $ im = new Imagick ();
63
+ $ im ->readImage ($ imgsource );
64
+ }else {
65
+ $ image = file_get_contents ($ imgsource );
66
+ }
67
+
68
+ break ;
69
+
70
+ case 'blob ' :
71
+ if (extension_loaded ('imagick ' )) {
72
+ $ im = new Imagick ();
73
+ $ im ->readimageblob ($ imgsource );
74
+ }else {
75
+ $ image = $ imgsource ;
76
+ }
77
+
78
+ break ;
79
+ }
57
80
58
81
if (extension_loaded ('imagick ' )) {
59
- $ im = new Imagick ();
60
- $ im ->readImage ($ filename );
61
82
$ width = $ im ->getImageWidth ();
62
83
$ height = $ im ->getImageHeight ();
63
84
$ source = new \Zxing \IMagickLuminanceSource ($ im , $ width , $ height );
64
85
}else {
65
- $ image = file_get_contents ($ filename );
66
- $ sizes = getimagesize ($ filename );
86
+ $ sizes = getimagesize ($ imgsource );
67
87
$ width = $ sizes [0 ];
68
88
$ height = $ sizes [1 ];
69
89
$ im = imagecreatefromstring ($ image );
You can’t perform that action at this time.
0 commit comments