Giter Site home page Giter Site logo

baconqrcode's People

Contributors

alien999999999 avatar arxeiss avatar ashleypinner avatar askdkc avatar athos-ribeiro avatar ausi avatar chris53897 avatar chris8934 avatar dasprid avatar github-actions[bot] avatar iben12 avatar ihaohong avatar ishanvyas22 avatar jercsi avatar kamil-tekiela avatar kelunik avatar michaeldyrynda avatar mustanggb avatar pavlm avatar pdalfarr avatar rodrigost23 avatar simplycorey avatar thinkscape avatar vincentlanglet avatar vivekwaah avatar weiting-sflx avatar williamdes avatar wyattoday avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

baconqrcode's Issues

quiet_zone=0 not working

Please make it possible to remove the white border/padding inside the image completely.
In endroid/QrCode this setting is called quiet_zone. I originally raised the issue there endroid/qr-code#95

download a file

Hello,

Can I configure so that when scanning the qr code automatically download a file?

ErrorCorrectionLevel H issue

Hi @DASPRiD,

When I generate a QR Code as follows I get a valid image.

$renderer = new \BaconQrCode\Renderer\Image\Png();
$renderer->setHeight(256);
$renderer->setWidth(256);
$writer = new \BaconQrCode\Writer($renderer);
$writer->writeFile('localhost/preinscription/1/f3a450d9545685097a486e7446730d9f/', 'qrcode.png', Encoder::DEFAULT_BYTE_MODE_ECODING, ErrorCorrectionLevel::L);

However when I increase the error correction level to ErrorCorrectionLebel::H I end up with an image that both my automated reader and my Android Barcode Scanner cannot read. Do you have any idea what could be the issue?

Thanks!

SimpleCircleEye Class not working properly.

This Path code create a circle with a weird edge can some guide me to fix it?

return (new Path())
			->move(1.5, 0)
			->ellipticArc(1.5, 1.5, 0., false, true, 0., 1.5)
			->ellipticArc(1.5, 1.5, 0., false, true, -1.5, 0.)
			->ellipticArc(1.5, 1.5, 0., false, true, 0., -1.5)
			->ellipticArc(1.5, 1.5, 0., false, true, 1.5, 0.)
			->close();

http://prntscr.com/jyxvd6

style dots and corners

If you can add more flexible feature to style qr such as this
download
I am very grateful!‌ 😁

QRCode gets trimmed because of margin when ImagickBackend is used with Gradient

Everything works fine with SVG but PNG has issues.
simple-qrcode v.4.1.0
php 7.4.13
imagick module 3.4.4

image

<?php
ini_set('display_errors', 1);

require_once '../vendor/autoload.php';

use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Renderer\Module\SquareModule;
use BaconQrCode\Renderer\Eye\SquareEye;
use BaconQrCode\Writer;
use BaconQrCode\Renderer\RendererStyle\Gradient;
use \BaconQrCode\Renderer\Color\Rgb;
use \BaconQrCode\Renderer\RendererStyle\{GradientType, EyeFill, Fill};

$size = 400;
$margin = 2;

$eye = SquareEye::instance();

$squareModule = SquareModule::instance();
$eyeFill = new EyeFill(new Rgb(100,100,55), new Rgb(100,100,255));

$format = $_GET['format'] ?? 'png';
$backend = ($format == 'png') ? new ImagickImageBackEnd() : new SvgImageBackEnd();


$gradient = new Gradient(new Rgb(100,100,55), new Rgb(100,100,255), GradientType::HORIZONTAL());

$renderer = new ImageRenderer(
    new RendererStyle($size, $margin, $squareModule, $eye, 
        Fill::withForegroundGradient(new Rgb(255,255,255), $gradient, $eyeFill, $eyeFill, $eyeFill)),
    $backend
);


$writer = new Writer($renderer);
if ($format == 'png') {
    header('Content-type: image/png');
}

echo $writer->writeString('https://apiroad.net/very-long-url');

Extendability

Hello,

So my customer wanted the left top eye to be a specific color like so:
Screenshot 2019-05-28 at 08 06 54
Now this was made possible using this package (yay)

However, achieving this was not as easy as I thought.
BaconQrCode\Renderer\RendererStyle\Fill has a constructor where you can specify every aspect of the code, however you made the constructor private for some reason which meant I had to extend, which is not possible because you made the class Final.
I made my own class, but then I had to extend BaconQrCode\Renderer\RendererStyle\RendererStyle because that constructor is public and uses interfaces, except for the Fill class. But alas RendereStyle is also final so I had to copy that class as well

Almost there, I also had to extend BaconQrCode\Renderer\ImageRenderer because it referenced RendererStyle, but also because of final I had to copy the entire class again.

What I am getting at is, are you open for a Pull Request that opens up the library for extensions build on top? e.g. making methods public/protected, make the classes extendable (no more final), and use interfaces for everything.

Because this is a little time consuming I figured I'd ask first if I could assist you with this or if I should create my own fork to implement changes I could use. (with no intention of PR)

Thanks for this package, it has helped me a lot.

Cheers,
RJ

Multiple QR Sizes on one page

If you generate multiple QR codes with different sizes on one page, the rect size used in the SVG file defaults to the first QR code on the page.

The problem seems to be the ID is the same ("r0") for each SVG file.

<defs><rect id="r0" width="4" height="4" fill="#000001"/></defs>

I expect my use case is very unusual.
I wasn't able to identify an elegant solution for this issue. The only idea I had was to add another method which lets you define your own ID which didn't seem very elegant.

QR code Generation fails depending on locale

The QR code generation does fail, depending on the locale if the decimal separator is not defined as a point.

This is caused by the library generating comma separated numbers in places where a point value is expected, for example <g transform="scale(10,811)"> instead of <g transform="scale(10.811)"> on de_DE as the float is transformed with a comma as a decimal separator by the sprintf including it as a string, basically casting float to string in the process.

Imagick png is also affected by the locale, although I haven't figured out exactly why yet.

Suggestion: add php gd to composer requirements

i try to use without install php gd and get this error:
PHP Fatal error: Call to undefined function BaconQrCode\Renderer\Image\imagecreatetruecolor() in /tmp/composer-project/vendor/bacon/bacon-qr-code/src/BaconQrCode/Renderer/Image/Png.php on line 42

i suggest to add this requirements to composer.json

performance comparison

Hi!

As part of researching ways of generating QR codes in my PHP application I did some simple performance tests comparing BaconQrCode against the CLI qrencode tool. I was expecting the BaconQrCode library to be faster than using passthru from PHP, but maybe it is not:

Method Requests / second
/usr/bin/qrencode 141.03 [#/sec] (mean)
BaconQrCode 1.0.3 34.49 [#/sec] (mean)
BaconQrCode master 8.10 [#/sec] (mean)
chillerlan/php-qrcode 20.63 [#/sec] (mean)

The example code I used with the CLI tool:

<?php
$qrString = 'otpauth://totp/foo%40example.org:My%20Service%20Inc.?secret=H7ISMUHIREODCOONJUOPKJJ4HJCS2PUD&algorithm=SHA1&digits=8&period=10&issuer=My%20Service%20Inc.';
ob_start();
passthru('/usr/bin/qrencode -s 5 -t PNG -o - ' . escapeshellcmd($qrString));
header('Content-Type: image/png');
echo ob_get_clean();

For BaconQrCode 1.0.3 I used this script:

<?php

$qrString = 'otpauth://totp/foo%40example.org:My%20Service%20Inc.?secret=H7ISMUHIREODCOONJUOPKJJ4HJCS2PUD&algorithm=SHA1&digits=8&period=10&issuer=My%20Service%20Inc.';

require_once 'bacon/vendor/autoload.php';

use BaconQrCode\Renderer\Image\Png;
use BaconQrCode\Writer;

$renderer = new Png();
$renderer->setHeight(256);
$renderer->setWidth(256);
$writer = new Writer($renderer);
header('Content-Type: image/png');
echo $writer->writeString($qrString);

For BaconQrCode from master I used this script:

<?php

$qrString = 'otpauth://totp/foo%40example.org:My%20Service%20Inc.?secret=H7ISMUHIREODCOONJUOPKJJ4HJCS2PUD&algorithm=SHA1&digits=8&period=10&issuer=My%20Service%20Inc.';

require_once 'bacon2/vendor/autoload.php';

use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;

$renderer = new ImageRenderer(
    new RendererStyle(256),
    new ImagickImageBackEnd()
);
$writer = new Writer($renderer);
header('Content-Type: image/png');
echo $writer->writeString($qrString);

I tested both with BaconQrCode 1.0.3 and BaconQrCode master on PHP 7.4 (Fedora 32) by accessing the script through Apache+FPM-FPM using Apache Bench to check the performance:

$ ab -n 1000 -c 50 https://HOST/qr.php

Is this performance difference expected? Is there anything that can be done to improve the performance of BaconQrCode, maybe specific opcache configuration? Am I testing wrong? Can the PHP code be optimized? Is Composer the bottleneck? Although I tested with phpab directly as well, which didn't help much... Is there a good reason not to consider using passthru with /usr/bin/qrencode?

Thanks

BaconQrCode\Exception\RuntimeException: You need to install the imagick extension to use this back end

Hello there,

I'm having an issue when trying to run phpunit together with this package:

1) Tests\Feature\PigeonIndexTest::a_user_can_only_see_their_own_pigeons
BaconQrCode\Exception\RuntimeException: You need to install the imagick extension to use this back end

C:\Users\aFluxx\Desktop\pigeome\vendor\bacon\bacon-qr-code\src\Renderer\Image\ImagickImageBackEnd.php:64
C:\Users\aFluxx\Desktop\pigeome\vendor\pragmarx\google2fa-qrcode\src\Google2FA.php:40
C:\Users\aFluxx\Desktop\pigeome\vendor\pragmarx\google2fa-laravel\src\Google2FA.php:31
C:\Users\aFluxx\Desktop\pigeome\vendor\pragmarx\google2fa-laravel\src\Support\Authenticator.php:37
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Container\Container.php:812
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Container\Container.php:658
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Container\Container.php:609
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:759
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php:121
C:\Users\aFluxx\Desktop\pigeome\vendor\pragmarx\google2fa-laravel\src\Middleware.php:12
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php:43
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes.php:30
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath.php:33
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect.php:56
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\mcamara\laravel-localization\src\Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter.php:45
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\app\Http\Middleware\MarkNotificationAsRead.php:24
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php:41
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php:75
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Session\Middleware\AuthenticateSession.php:58
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php:49
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php:63
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php:37
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php:66
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Router.php:694
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Router.php:668
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Router.php:633
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Router.php:622
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:176
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
C:\Users\aFluxx\Desktop\pigeome\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php:58
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\fideloper\proxy\src\TrustProxies.php:57
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:31
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:31
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php:62
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:163
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:151
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:116
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:345
C:\Users\aFluxx\Desktop\pigeome\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\MakesHttpRequests.php:168
C:\Users\aFluxx\Desktop\pigeome\tests\Feature\PigeonIndexTest.php:51

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Script .\vendor\bin\phpunit handling the test event returned with error code 2

I'm trying to run sq_lite in ;memory: any idea how I can fix this?

not support muti-bytes-char,such as cjk(china,japan,korea)

source:

setHeight(256); $renderer->setWidth(256); $writer = new \BaconQrCode\Writer($renderer); $writer->writeFile('http://www.baidu.com?keywords=汉字', 'qrcode.png'); ?>

output:

PHP Fatal error: Uncaught BaconQrCode\Exception\WriterException: Could not encode content to ISO-8859-1 in E:~tmp\test\src\BaconQrCode\Encoder\Encoder.php:628
Stack trace:
#0 E:~tmp\test\src\BaconQrCode\Encoder\Encoder.php(539): BaconQrCode\Encoder\Encoder::append8BitBytes('http://www.baid...', Object(BaconQrCode\Common\BitArray), 'ISO-8859-1')
#1 E:~tmp\test\src\BaconQrCode\Encoder\Encoder.php(86): BaconQrCode\Encoder\Encoder::appendBytes('http://www.baid...', Object(BaconQrCode\Common\Mode), Object(BaconQrCode\Common\BitArray), 'ISO-8859-1')
#2 E:~tmp\test\src\BaconQrCode\Writer.php(82): BaconQrCode\Encoder\Encoder::encode('http://www.baid...', Object(BaconQrCode\Common\ErrorCorrectionLevel), 'ISO-8859-1')
#3 E:~tmp\test\src\BaconQrCode\Writer.php(103): BaconQrCode\Writer->writeString('http://www.baid...', 'ISO-8859-1', 1)
#4 E:~tmp\test\index.php(7): BaconQrCode\Writer->writeFile('http://www.baid...', 'qrcode.png')
#5 {main}

thrown in E:~tmp\test\src\BaconQrCode\Encoder\Encoder.php on line 628

Possible bug with non-centered EPS code

Thank you for this great QR code encoder.

When generating EPS images the QR code is not centered vertically but the top margin/padding is too small.
A small change in bacon\bacon-qr-code\src\BaconQrCode\Renderer\Image\Eps.php seems to fix that.

Function drawBlock:

from
$this->eps .= ($x . " " . ($this->finalHeight - $y) . " " . $this->blockSize . " " . $this->blockSize . " F\n";

to:
$this->eps .= $x . " " . ($this->finalHeight - $y - $this->blockSize) . " " . $this->blockSize . " " . $this->blockSize . " F\n";

Thanks again for your effort

Open for PR for a GD renderer?

Hi,

I see lots of unanswered issues and pull requests so I wanted to check before investing a lot of time.

Are you open to accepting a PR that will add a GD based renderer?

Is the image required to exist before you generate the qr code?

Hi there ,
I tried using your sample code on both an existing image and a non-existing image .
Both case failed , and no image is generated on the latter.
first trial:
$renderer = new \BaconQrCode\Renderer\Image\Png(); $renderer->setHeight(256); $renderer->setWidth(256); $writer = new \BaconQrCode\Writer($renderer); $writer->writeFile('Hello World!', 'qrcode.png');

i then thought i could just write string instead of writing into a file but when i echo i still don't get image
2nd trial :

`
$renderer = new \BaconQrCode\Renderer\Image\Png();

        $renderer->setHeight(256);

        $renderer->setWidth(256);

        $writer = new \BaconQrCode\Writer($renderer);

        $str= $writer->writeString('Hello World!');
       header('Content-Type:image/png');
      echo $str;`

i get the code below

�PNG � IHDR������?1��IDATx����n�0�A'�����k��P!��؝9�����������~�������' �4��&��@�H�i� M� �4��&��@�H�i� M� �4��&��@�H�i� M� �4��&��@�H�i� M� �4��&��@�H�i� M� �4������x�^���3:|��������u�+W�_u?O��9�p�'����4��&��@�H�i#�W�Z'^��?m=�������|�H�i� M� �4��6z�peպ�u�U�럾N?����<�H�i� M� �4��&Ҏ�����@�'i� M� �4��&��@�9�F�� ��<�H�i� M� �4��&Ҏ��L[/�v?w�~�?� @�H�i� M� �4��6z�0�|�?�>�A�|����!M� �4��&��@�H�*����}���� M� �4��&��@�H�����S_��������w�'��� @�H�i� M� �4��6b����u�����Ͽ�I�&��@�H�i� M�����_��u�Lx��_<�^��������i� M� �4��&�F��V�ǯz��ʴu��s�Us���Y�Q�0��&��@�H�i� m�9�������U���w�|�J� �4��&��@�H�1�8�)��ᄒs��0� M� �4��&��@ڈ9���v���G��>E������̓M�@�H�i� M� �����\������<��������'i� M� �4��&��@��9�����=���)� ��'i� M� �4��&��@ڑs�iv��?��?�'i� M� �4��&��@�9�FO�{�j>P�3x��&��@�H�i� M��9�8e�yչ����_�sw��>���4��&��@�H�i� m�����kv��OX���F�H�i� M� �4���5y��v�� M� �4��&��@�H�i� M� �4��&��@�H�i� M� �4��&��@�H�i� M� �4��&��@�H�i� M� �4��&��@�H�i� M� ���mF��sE�}IEND�B

What's the problem ?

Why was the autoloader removed?

I was just wondering why the autoloader was removed? I just updated to the latest version and had to map all the classes myself. It's not a big deal, but was there a specific reason for this?

transparency

is there any option to have a image (png , svg) with transparent background?

Cyrillic symbols

Hey,
Would you library support russian symbols? I've got the Exception while creating QR code - Could not encode content to ISO-8859-1.

Thank you for help.

[BUG?] Generated QR Codes have different padding

Hi there,

Thanks for the great library!

The code:

$a = '{"i":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","v":1,"t":1,"d":"9ZGeRh5hsoYuSW8uT0NZyXMa17FOPTa28Ykt8th9\/XP7PGNgcxXUbZwtcPB\/5hql","ud":"--","un":105}';
$renderer = new \BaconQrCode\Renderer\Image\Png();
$renderer->setHeight(210);
$renderer->setWidth(210);
$renderer->setMargin(0);
$writer = new \BaconQrCode\Writer($renderer);
$writer->writeFile($a, 'qrcode1.png', 'UTF-8', 2);

$b = '{"i":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","v":1,"t":1,"d":"\/x6lV8xzx4QpZ6zhyl0jbxKfn5XB8xnCwmrajnTqvwRyqAXn+3DIG+HvmAdhY3a0","ud":"{\"a\":5}-","un":667}';
$renderer = new \BaconQrCode\Renderer\Image\Png();
$renderer->setHeight(210);
$renderer->setWidth(210);
$renderer->setMargin(0);
$writer = new \BaconQrCode\Writer($renderer);
$writer->writeFile($b, 'qrcode2.png', 'UTF-8', 2);

Results in the following images:

qrcode1
qrcode2

Big padding is added to the second PNG, while first one is very close to the required 210x210 dimension.

Thanks!

failing tests in PHP 7.1?

PHPUnit 5.6.5 by Sebastian Bergmann and contributors.
.....F.......................EE..E.............................  63 / 165 ( 38%)
............................................................... 126 / 165 ( 76%)
.......................................                         165 / 165 (100%)
Time: 304 ms, Memory: 6.00MB
There were 3 errors:
1) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #2 (4, 19, 1, 1, 4)
RuntimeException: Index invalid or out of range
/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:76
2) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #3 (5, 37, 1, 1, 6)
RuntimeException: Index invalid or out of range
/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:76
3) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #6 (8, 285, 1, 1, 32)
RuntimeException: Index invalid or out of range
/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:76
--
There was 1 failure:
1) BaconQrCode\Common\BitArrayTest::testGetNextSet5
Failed asserting that 64 matches expected 67.
/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/BitArrayTest.php:123
ERRORS!
Tests: 165, Assertions: 79424, Errors: 3, Failures: 1.

[Unreported] Call to undefined function BaconQrCode\Renderer\Image\imagecreatetruecolor

Hi,
I am using Laradock to run Nginx, PHP 7.3, MariaDB, php-worker and Redis.
I setup QUEUE_DRIVER=redis and laravel-worker.conf as below:
[program:myproject-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/www/myproject/artisan queue:work redis --tries=1 autostart=true autorestart=true numprocs=2 user=root redirect_stderr=true stdout_logfile=/var/www/myproject/worker.log
When I run docker-compose up php-worker, the job was failed with error Call to undefined function BaconQrCode\Renderer\Image\imagecreatetruecolor().
The weird thing is if I stop php-worker but manually run php artisan queue:work redis --tries=1 then job processed successfully.
Do you think it is a bug or something?
Thanks :)

32-bit architecture test suite failure and hang

All tests but testFindMsbSet

# phpunit   --filter '(::test(?!FindMsbSet))'
PHPUnit 5.7.21 by Sebastian Bergmann and contributors.

.....E..F.E..E.............EEEEEEE.............................  63 / 164 ( 38%)
............................................................... 126 / 164 ( 76%)
......................................                          164 / 164 (100%)

Time: 98 ms, Memory: 4.00MB

There were 10 errors:

1) BaconQrCode\Common\BitArrayTest::testGetNextSet5
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/BitArrayTest.php:98

2) BaconQrCode\Common\BitMatrixTest::testGetSet
ArithmeticError: Bit shift by negative number

/builddir/build/BUILDROOT/php-bacon-qr-code-1.0.1-2.fc26.remi.i386/usr/share/php/BaconQrCode/Common/BitUtils.php:35
/builddir/build/BUILDROOT/php-bacon-qr-code-1.0.1-2.fc26.remi.i386/usr/share/php/BaconQrCode/Common/BitMatrix.php:84
/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/BitMatrixTest.php:31

3) BaconQrCode\Common\BitMatrixTest::testRectangularSetRegion
ArithmeticError: Bit shift by negative number

/builddir/build/BUILDROOT/php-bacon-qr-code-1.0.1-2.fc26.remi.i386/usr/share/php/BaconQrCode/Common/BitUtils.php:35
/builddir/build/BUILDROOT/php-bacon-qr-code-1.0.1-2.fc26.remi.i386/usr/share/php/BaconQrCode/Common/BitMatrix.php:84
/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/BitMatrixTest.php:85

4) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #0 (2, 7, 1, 1, 1)
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:42

5) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #1 (3, 11, 1, 1, 2)
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:42

6) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #2 (4, 19, 1, 1, 4)
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:42

7) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #3 (5, 37, 1, 1, 6)
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:42

8) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #4 (6, 67, 1, 1, 8)
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:42

9) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #5 (7, 137, 1, 1, 10)
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:42

10) BaconQrCode\Common\ReedSolomonTest::testCodec with data set #6 (8, 285, 1, 1, 32)
mt_srand() expects parameter 1 to be integer, float given

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/ReedSolomonCodecTest.php:42

--

There was 1 failure:

1) BaconQrCode\Common\BitArrayTest::testGetArray
Failed asserting that -2147483648 matches expected 2147483648.0.

/builddir/build/BUILD/BaconQrCode-031a2ce68c5794064b49d11775b2daf45c96e21c/tests/BaconQrCode/Common/BitArrayTest.php:170

ERRORS!
Tests: 164, Assertions: 8559, Errors: 10, Failures: 1.

Only testFindMsbSet

# phpunit   --filter '(::testFindMsbSet)' --debug
PHPUnit 5.7.21 by Sebastian Bergmann and contributors.


Starting test 'BaconQrCode\Encoder\MatrixUtilTest::testFindMsbSet'.

Process hangs forever

Failing tests on i386 and armhf

There was 1 failure:
1) BaconQrCodeTest\Common\BitArrayTest::testGetArray
Failed asserting that -2147483647-1 is identical to 2147483648.0.
/builds/php-team/pear/php-bacon-baconqrcode/debian/output/source_dir/test/Common/BitArrayTest.php:191
There was 1 failure:
1) BaconQrCodeTest\Common\BitArrayTest::testGetArray
Failed asserting that -2147483647-1 is identical to 2147483648.0.
/builds/php-team/pear/php-bacon-baconqrcode/debian/output/source_dir/test/Common/BitArrayTest.php:191

https://salsa.debian.org/php-team/pear/php-bacon-baconqrcode/-/jobs/1048488#L1460

More errors here: https://salsa.debian.org/php-team/pear/php-bacon-baconqrcode/-/jobs/1048488#L1412

Why are error correction level constants protected?

I want to be able to set the error correction level of a QR by passing a param to the writer, as it permits. I have no need to know precisely what these values are, so it makes sense to pick a constant to say it for me, and I have seen some code in this repo that does exactly that, for example:

$writer->writeFile('hello', "code.png", Encoder::DEFAULT_BYTE_MODE_ECODING, ErrorCorrectionLevel::H);

However this no longer works because those constants are protected and thus can't be accessed from outside. The only option available is via the forBits() method – but in order to use that I need to know the bit numbers the levels correspond to, which makes no sense to me! So to get H level, I have to say:

$writer->writeFile('hello', "code.png", Encoder::DEFAULT_BYTE_MODE_ECODING, ErrorCorrectionLevel::forBits(2));
// or
$writer->writeFile('hello', "code.png", Encoder::DEFAULT_BYTE_MODE_ECODING, 0x02);

It's doubly confusing because the levels are not in any guessable order. Is this a mistake, or should I specify the correction level in some other way?

Issue in Scanning Kanji QR code using camera in xamarin in Release Mode

I have implemented an Xamarin App which uses the zxing library for scan the QR. When app is deployed to android device in debug mode it scan the QR but not in RELEASE MODE. Can you suggest me the best way to fix this issue.?

ZXing.Net.Mobile nuget version 2.4.1

Here I have added code snippet which I have used. Also the QR code.

image

image

No way to specify input is bytes

Hello,

I'm compressing some data before encoding the QR code to save space, but there doesn't seem to be a way to specify that the input should be left as is, without character set handling.

Attempting to use a BZCompressed string with the encoder gives me an error like the following:

Stack trace:
#0 /home/kate/Projects/QRCode/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(511): BaconQrCode\Encoder\Encoder::append8BitBytes()
#1 /home/kate/Projects/QRCode/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(76): BaconQrCode\Encoder\Encoder::appendBytes()
#2 /home/kate/Projects/QRCode/vendor/bacon/bacon-qr-code/src/Writer.php(52): BaconQrCode\Encoder\Encoder::encode()
#3 /home/kate/Projects/QRCode/vendor/bacon/bacon-qr-code/src/Writer.php(66): BaconQrCode\Writer->writeString()
#4 /home/kate/Projects/QRCode/test.php(59): BaconQrCode\Writer->writeFile()
#5 {main}
  thrown in /home/kate/Projects/QRCode/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php on line 598

Would this be an appropriate use for CP437?

Class not found

on 2.0.0 version Class 'BaconQrCode\Renderer\Image\Png' not found
but 1.0.3 version works

PHP 7.4 Array and string offset access syntax with curly braces is deprecated

The use of curly braces is deprecated in 7.4 and throws an exception.

There are many examples but on of them
/picqer/php-barcode-generator/src/BarcodeGenerator.php:293
for ($i = 0; $i < $clen; ++$i) { $char = $code{$i}; ... }

Distributor ID: Ubuntu
Description: Ubuntu 16.04.7 LTS
Release: 16.04
Codename: xenial
PHP 7.4.12 (cli) (built: Oct 31 2020 17:03:53) ( NTS )

TransformationMatrix calculations wrong(?)

Heyho,
I am trying to prepare a PR to support gd again, at least for non gradient drawing as mvp, but i have a problem with the transformation-matrix:

$matrix = TransformationMatrix::scale(2);
var_dump($matrix->apply(1, 2));
die();

I got as result sth like (2, 2), but it should be (2, 4). I have the feeling the matrix-calculations are wrong. Sadly i lost a lot of knowledge of matrixes over the years so i dont know how to fix and make a PR by my own.

Does anyone has an idea?

QR code version

Is there any way to set QR code version?

Example

If I generate QR code of string with length of 20 bytes and 'M' error correction level, I will most likely get QR version 1, but I need it to QR version 15 (77x77grid).

Quick Reference

Might it be possible to at least get a quick list of available methods in this library?

For example: I was unable to figure out how to increase the error correction level, although I saw many references to it throughout the library. I was able to take the example in the readme and stream the output by changing the $writer->writeFile to $writer->writeString, but the rest is a little difficult to determine without a lot of guesswork... at least for those of us that haven't earned our OOP merit badges yet.

Thanks!

Imagick extention

When I try to use BaconQrCode features i get this message BaconQrCode\Exception\RuntimeException : You need to install the imagick extension to use this back end and I have imagick instaled on my homestead

Max length for string

Hello,
What is the maximum length size of a generated string?
Do we have relation between "string length" to "size()" function?
Do we have relation between "string length" to "errorCorrection('*_Change to Char_')"?

10xxxx, Lior :)

Stable?

Can we mark this as stable or are further changes planned? @DASPRiD

I currently have this marked as a dependency for one of my projects and it will not install unless minimum-stability is set to dev.

Thank you. 😄

Class 'PHPUnit_Framework_TestCase' not found

Hello,

First I update composer so Vendor folder create, In that All Package like phpunit,etc...

Then

When I run encodetest file for testing purpose , It throw error Below.

Error:

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in D:\xampp\htdocs\demo\BaconQrCode-master\tests\BaconQrCode\Encoder\EncoderTest.php on line 22

image

Can you help me for solve this error.

Thanks&Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.