Closed elnath78 closed 5 months ago
There is an open pull requests for an alternate GdLibRenderer
, but that one hasn't been processed yet:
https://github.com/Bacon/BaconQrCode/pull/114
@elnath78 as noted above, there is open PR for that. If you want, add this to your composer.json
.
It works, I'm using it on production for one client. And trying to keep up to date with latest changes.
P.S. There is another reason not to use Imagick. When QR code is too large it was failing for me locally with some kind a weird exception that the path was too complex.
"repositories": [
{
"type": "vcs",
"url": "https://github.com/arxeiss/BaconQrCode"
}
],
"require": {
...
"bacon/bacon-qr-code": "dev-add-gd-backend#650e10121f4d8707ecdc5984b042cae7731e388a",
@arxeiss I tried the Bacon path but it is incredibly slow, tested on local and it averaged 1.76 seconds to generate a QR code, I tested the various available formats. Eventually I decided to use the Google service for QR Code generation, and although it does a remote connection, it is super fast, the average was 0.08 seconds. The only concern is about GDPR, the other possible solution would be generate QR Codes then serve them as users join and request them, possibly an async service that generate a QR Code when the user signs up and serve it ready when he decides to switch to 2FA login.
How big your QR code is? I tested it locally:
@arxeiss This is what I did, using multiple formats as well:
use BaconQrCode\Renderer\ImageRenderer;
//use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
//use BaconQrCode\Renderer\Image\EpsImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
$renderer = new ImageRenderer(
new RendererStyle(300),
new SvgImageBackEnd()
);
//$uri has the URL formatted for QR Code
$writer = new Writer($renderer);
$writer->writeFile($uri, 'qrcode.svg');
Resolved by #171
I'm not sure ifthis was already discussed, but I find much more practical to have GD support than Imagick, iirc GD is natively present in recent PHP intallations, while Imagick must be installed separately, configured and you need to pray it works.