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 4848
4949final class QrReader
5050{
51+ const SOURCE_TYPE_FILE = 'file ' ;
52+ const SOURCE_TYPE_BLOB = 'blob ' ;
5153 public $ result ;
5254
53- function __construct ($ filename )
55+ function __construct ($ imgsource , $ sourcetype = ' file ' )
5456 {
5557
5658 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+ }
5780
5881 if (extension_loaded ('imagick ' )) {
59- $ im = new Imagick ();
60- $ im ->readImage ($ filename );
6182 $ width = $ im ->getImageWidth ();
6283 $ height = $ im ->getImageHeight ();
6384 $ source = new \Zxing \IMagickLuminanceSource ($ im , $ width , $ height );
6485 }else {
65- $ image = file_get_contents ($ filename );
66- $ sizes = getimagesize ($ filename );
86+ $ sizes = getimagesize ($ imgsource );
6787 $ width = $ sizes [0 ];
6888 $ height = $ sizes [1 ];
6989 $ im = imagecreatefromstring ($ image );
You can’t perform that action at this time.
0 commit comments