Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#php qr decoder
> php识别二维码, 不需要安装扩展 从哪里弄来的我也忘了,毕竟好几年了
## PHP QR Decoder

### 安装
`composer require zxing/qr-reader`
### How to install
`composer require thiagolp90/qr-reader`

### 使用
> this package is a fork of `zxing/qr-reader` to fix a bug when reading file using GD

### How to use
```
include __DIR__.'/vendor/autoload.php';

$qrcode = new \Zxing\QrReader('./qr.png'); //图片路径
$text = $qrcode->text(); //返回识别后的文本
$qrcode = new \Zxing\QrReader('./qr.png'); //Image path
$text = $qrcode->text(); //Return text
echo $text;
```

### 需要
### Requirements
```
PHP >= 5.3
GD Library
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "zxing/qr-reader",
"name": "thiagolp90/qr-reader",
"description": "PHP qr code reader library",
"keywords": [
"php",
Expand Down
6 changes: 3 additions & 3 deletions lib/GDLuminanceSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function GDLuminanceSource($gdImage, $width, $height)
$this->dataHeight = $height;
$this->left = 0;
$this->top = 0;
$this->$gdImage = $gdImage;
$this->gdImage = $gdImage;


// In order to measure pure decoding speed, we convert the entire image to a greyscale array
Expand All @@ -64,8 +64,8 @@ public function GDLuminanceSource($gdImage, $width, $height)

for($j=0;$j<$height;$j++){
for($i=0;$i<$width;$i++){
$argb = imagecolorat($this->$gdImage, $i, $j);
$pixel = imagecolorsforindex($this->$gdImage, $argb);
$argb = imagecolorat($this->gdImage, $i, $j);
$pixel = imagecolorsforindex($this->gdImage, $argb);
$r = $pixel['red'];
$g = $pixel['green'];
$b = $pixel['blue'];
Expand Down