karmabunny/bacon-backends
最新稳定版本:v1.0.0
Composer 安装命令:
composer require karmabunny/bacon-backends
包简介
README 文档
README
Some extra backends for Bacon QR.
These might work a bit more reliably than others, particularly in constrained hosting environments.
- ImagickDumbBackEnd
- GdImageBackEnd
ImagickDumbBackEnd
The built-in imagick backend is (currently) broken in PHP 8. So this is a backend that wraps the SVG backend and pipes it through the convert CLI tool provided by imagick.
Generally we've found the PHP imagick extension a bit questionable anyway. Sprout 3, for example, departed from the imagick extensions in Sprout 2 and uses the convert tool exclusively.
Caveats: Might not work on Windows. Makes heavy use of proc_open().
GdImageBackEnd
This is a very limited backend but has enough bits to draw a basic QR code.
GD is widely available, more than imagick. So this is a big win for those tight environments.
Caveats: Many.
- No gradients.
- No rotation.
- No layers.
- No curves or ellipsis.
You might ask, why not write a renderer instead of an image backend? The answer is - I didn't even realise that was an option. It might be easier, might be harder. Might actually be far more robust. So maybe that's a thing for the future.
Usage
use BaconQrCode\Renderer\ImageRenderer; use BaconQrCode\Renderer\RendererStyle\RendererStyle; use BaconQrCode\Writer; use karmabunny\BaconBackends\GdImageBackEnd; use karmabunny\BaconBackends\ImagickDumbBackEnd; $renderer = new ImageRenderer( new RendererStyle(400), new ImagickDumbBackEnd(), // or new GdImageBackEnd(), ); $writer = new Writer($renderer); $writer->writeFile('Hello World!', 'qrcode.png');
Contributing
Be sure to write a test. We've got some pretty funky stuff going on in there but it validates the use case.
Run tests with composer test.
Pleas also run composer analyse over anything before releasing.
Future
Some things to do, for fun and profit.
- GD renderer (as opposed to the image backend)
- HTML renderer
统计信息
- 总下载量: 316
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-26