bacon/bacon-qr-code
Composer 安装命令:
composer require bacon/bacon-qr-code
包简介
BaconQrCode is a QR code generator for PHP.
README 文档
README
Introduction
BaconQrCode is a port of QR code portion of the ZXing library. It currently only features the encoder part, but could later receive the decoder part as well.
As the Reed Solomon codec implementation of the ZXing library performs quite slow in PHP, it was exchanged with the implementation by Phil Karn.
Example usage
use BaconQrCode\Renderer\ImageRenderer; use BaconQrCode\Renderer\Image\ImagickImageBackEnd; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; $renderer = new ImageRenderer( new RendererStyle(400), new ImagickImageBackEnd() ); $writer = new Writer($renderer); $writer->writeFile('Hello World!', 'qrcode.png');
Available image renderer back ends
BaconQrCode comes with multiple back ends for rendering images. Currently included are the following:
ImagickImageBackEnd: renders raster images using the Imagick librarySvgImageBackEnd: renders SVG files using XMLWriterEpsImageBackEnd: renders EPS files
GDLib Renderer
GD library has so many limitations, that GD support is not added as backend, but as separated renderer.
Use GDLibRenderer instead of ImageRenderer. These are the limitations:
- Does not support gradient.
- Does not support any curves, so you QR code is always squared.
Example usage:
use BaconQrCode\Renderer\GDLibRenderer; use BaconQrCode\Writer; $renderer = new GDLibRenderer(400); $writer = new Writer($renderer); $writer->writeFile('Hello World!', 'qrcode.png');
Known issues
ImagickImageBackEnd: white pixel artifacts
When using ImagickImageBackEnd, single white pixels may appear inside filled regions. This is
most visible with margin 0 (where artifacts appear at the image edge), but can in theory occur at
any position. The cause is a bug in ImageMagick's path fill rasterizer (GetFillAlpha in
MagickCore/draw.c): an off-by-one error in the winding number calculation combined with an edge
skipping bug in the scanline processing can incorrectly classify pixels as outside the polygon.
The bug cannot be reliably worked around in this library:
- Canvas padding (rendering on a larger canvas and cropping) does not work because the required padding depends on the scale factor, path complexity, and ImageMagick's internal edge processing state. No fixed padding value is safe for all inputs.
- Post-processing (scanning for and fixing isolated white pixels) risks corrupting legitimate rendering features such as curved module edges.
For artifact-free output, use SvgImageBackEnd or GDLibRenderer instead.
Development
To run unit tests, you need to have Node.js and the pixelmatch library installed. Running
npm install will install this for you.
bacon/bacon-qr-code 适用场景与选型建议
bacon/bacon-qr-code 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 186.2M 次下载、GitHub Stars 达 2.08k, 最近一次更新时间为 2013 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bacon/bacon-qr-code 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bacon/bacon-qr-code 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 186.2M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2145
- 点击次数: 56
- 依赖项目数: 395
- 推荐数: 34
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2013-03-30