robbiep/zbar-qrdecoder

一个用于Zbar的PHP包装器。用于解码包含二维码的图像/照片。

2.0.2 2016-03-13 16:05 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:08:27 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

这是一个zbar-tools的PHP包装器 - 目前仅支持zbarimg。请参阅http://zbar.sourceforge.net/

要求

  • zbar-tools - 在Ubuntu上安装,只需执行sudo apt-get install zbar-tools即可。有关更多平台,请参阅他们的项目页面
  • ImageMagick - Zbar需要它,我不确定他们是否打包了它,所以请确保您有它。

安装

通过Composer安装此包。

将以下内容添加到您的composer.json依赖项中

"require": {
   "robbiep/zbar-qrdecoder": "^2.0"
}

运行composer install下载所需文件。

用法

require_once('vendor/autoload.php');

$ZbarDecoder = new RobbieP\ZbarQrdecoder\ZbarDecoder();

# Optionally change the path of the zbarimg executable if you need to (default: /usr/bin)
$ZbarDecoder->setPath('/usr/local/bin');

# Decode the image
$result = $ZbarDecoder->make('/a/path/to/image_with_barcode.jpg');

echo $result; // Outputs the decoded text
echo $result->format; // Outputs the barcode's format
echo $result->code; // 200 if it decoded a barcode OR 400 if it couldn't find a barcode.

如果您在Laravel中使用它...

如果您需要更改任何选项,我已包括一个ServiceProvider类和配置。您需要将ServiceProvider添加到config/app.php

'providers' => array(
    ...
    'RobbieP\ZbarQrdecoder\ZbarQrdecoderServiceProvider'
)

您可能需要发布配置php artisan vendor:publish

现在您可以在Laravel应用程序中使用Zbar QR Decoder了!

Laravel中的用法

# Decode the image
$result = ZbarDecoder::make('/a/path/to/image_with_barcode.png');

echo $result; // Outputs the decoded text
echo $result->format; // Outputs the barcode's format

支持的其他条码

  • EAN_13 / ISBN
  • CODE_39
  • CODE_128

贡献

  1. 分支它
  2. 创建您的功能分支:git checkout -b my-new-feature
  3. 提交您的更改:git commit -am '添加一些功能'
  4. 推送到分支:git push origin my-new-feature
  5. 提交一个pull请求