BaconQrCode is a port of QR code portion of the ZXing library

Related tags

Imagery BaconQrCode
Overview

QR Code generator

Build Status Coverage Status Latest Stable Version Total Downloads License

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 library
  • SvgImageBackEnd: renders SVG files using XMLWriter
  • EpsImageBackEnd: renders EPS files
Comments
  • Imagick extention

    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

    opened by GoncaloRod 26
  • Failing tests on i386 and armhf

    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

    wontfix 
    opened by williamdes 14
  • Want to add new Eye and QRcode styles - Not an issue looking for optimal suggestions

    Want to add new Eye and QRcode styles - Not an issue looking for optimal suggestions

    I am looking to add a new QR Code style which will look like the following

    image

    Users will only be able to update the inner color of the eye.

    Full Description of the new required designs is described in the following screenshot

    image

    I am looking for an optimal way to achieve this task.

    Thanks in advance

    opened by hafizSiddiq7675 13
  • possible infection in

    possible infection in "Modules.php" file

    Hello, I would like to ask if in your source code there is a file called "Modules.php" A colleague tells me that on his website, passing wordfence, a path appears: "wp-content / mu-plugins / nue / vendor / bacon / bacon-qr-code / Modules.php" detected as malware.

    I have downloaded your .zip and I don't see that it has that file. This installation is normal in mu-plugins / nue

    Thansk

    question 
    opened by Kali-Gula 10
  • ErrorCorrectionLevel H issue

    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!

    opened by endroid 9
  • Correct HHVM Issue

    Correct HHVM Issue

    Fixes an HHVM bug that results with the following exception: max(): Array must contain at least one element.

    Please merge and release a 1.0.1. We use this heavily as a dependency. Thank you!

    opened by SimplyCorey 7
  • Debian adjustments and project improvements

    Debian adjustments and project improvements

    Since the last version that added a new dependency to run tests I can not package it in Debian, I made one adjustment to allow me to --exclude-group integration and just have to remove use MatchesSnapshots; on Debian.

    I also made changes to make everybody happy, exclude the tests from composer archives and allow me to have them in Debian

    opened by williamdes 6
  • Performance issue in BaconQrCode\Encoder

    Performance issue in BaconQrCode\Encoder

    Hi!

    I'm using the sprain/php-swiss-qr-bill library to generate QR-ESRs. Generating a single QR-ESR takes ~5 seconds (or more).

    Then I started the profiler and debugged it manually until I found that only the BaconQrCode\Encoder::chooseMaskPattern needed nearly all of this time. The time for PDF rendering etc. is nothing compared to this single method.

    https://github.com/Bacon/BaconQrCode/blob/master/src/Encoder/Encoder.php#L233-L252

    My question, is there a possibility to pass "some arguments" to make it faster to generate the QR code?

    opened by odan 6
  • PHP 8.1: Implicit conversion from float 26.666666666666664 to int loses precision

    PHP 8.1: Implicit conversion from float 26.666666666666664 to int loses precision

    public static function getDataMaskBit($maskPattern, $x, $y) { ... case 4: $intermediate = (BitUtils::unsignedRightShift($y, 1) + ($x / 3)) & 0x1;

    the term $x / 3 must not be an integer. Can you please round the term?

    opened by cscrewsandcaptains 5
  • Included 'return', for ease of testing on QRCode generation.

    Included 'return', for ease of testing on QRCode generation.

    With the addition of the 'return' statement, it facilitates the creation of unit tests for QR Code generator. Allowing you to test whether the file was generated or not.

    opened by Diego-Brocanelli 5
  • 32-bit architecture test suite failure and hang

    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

    opened by remicollet 5
  • Eye Square with Rounded Corner - Just a Question, not an Issue

    Eye Square with Rounded Corner - Just a Question, not an Issue

    I'm trying to write a new Module Renderer for Eye(internal and external) in order to get Square with Rounded Corner(not circle) but not sure how to get that.

    I mean, using matrix logic how to achieve this?

    For Circle I use this one:

          ->move(3.5, 0)
          ->ellipticArc(3.5, 3.5, 0., false, true, 0., 3.5)
          ->ellipticArc(3.5, 3.5, 0., false, true, -3.5, 0.)
          ->ellipticArc(3.5, 3.5, 0., false, true, 0., -3.5)
          ->ellipticArc(3.5, 3.5, 0., false, true, 3.5, 0.)
          ->close()
    
          ->move(2.5, 0)
          ->ellipticArc(2.5, 2.5, 0., false, true, 0., 2.5)
          ->ellipticArc(2.5, 2.5, 0., false, true, -2.5, 0.)
          ->ellipticArc(2.5, 2.5, 0., false, true, 0., -2.5)
          ->ellipticArc(2.5, 2.5, 0., false, true, 2.5, 0.)
          ->close()
    

    Should I focus on replacing ellipticArc with a combination of line() and curve()?

    Expected result: qr-code

    opened by SergiuPogor 1
  • How do you use this?

    How do you use this?

    There are no instructions on how to add a URL and Email?

    $renderer = new ImageRenderer(
          new RendererStyle(400),
          new SvgImageBackEnd()
        );
        $writer = new Writer($renderer);
        $qr =  $writer->writeString($this->phone);
    

    I can write the phone number or the email or the URL but how can you combine all of these?

    opened by movepixels 1
  • Add GD Image backend

    Add GD Image backend

    My client's web hosting provider sucks, and they don't have support for Imagick, even though they are promising it will be added.

    I'm generating QR codes for payment, which is added into email body. And email client's do not have nice support for SVG. So I need old-school GD support.

    However, GD has limited sets of functions. I believe, that it is OK, when that backend will have also limited sets of features. So this is not supported:

    • Any roundness like DotsModule, RoundnessModule or SimpleCircleEye
    • Gradients

    And because GD does not support Paths like Imagick or SVG do, I need to generate a bit different paths, so they are not so complex.

    opened by arxeiss 10
  • In simple Qr-code plugin for Laravel

    In simple Qr-code plugin for Laravel "You need to install ImageMagick" bug

    For Laravel 8, running PHP 7.4 or PHP 8.

    I have installed the simplesoftwareio / simple-qrcode plugin. It worked fine in PHP 5.4 but we are trying to upgrade.

    Now when I upgrade and try to use the code to generate the QR code, we get this error.

    "You need to install the imagick extension to use this backend".

    ~/src/Renderer/Image/ImagickImageBackEnd.php:64

    But imagick IS INSTALLED. I found many other people with this same problem (so I'm not crazy here) and they all resolved in downgrading to BaconQrCode version 1.0.3. But Laravel 8 won't let me do that, because of requirements.

    So I'm just stuck and wondering if this can be fixed?

    Screenshot 2022-07-19 123529

    opened by b-art-xx 7
  • Excessive version selected, mode optimisation support?

    Excessive version selected, mode optimisation support?

    I'm generating a QR from a URL that has 48 ASCII chars and using Q redundancy, which should mean the total data size is 60 bytes. For that amount of data, this library generates a 37x37 version 5 QR. Looking at this chart, I can see that the capacity of a version 5 does correspond to 60 bytes in "binary" mode, but version 4 can accommodate 67 bytes in "alphanumeric" mode. This chart shows that that this set includes :, ., and / which is all that's needed for URL support, but it does not support lower-case chars. So now I'm mystified because I have a QR generated by a different system that is a version 4 and successfully encodes my URL containing lower-case chars with the correct degree of redundancy.

    I suspect that this is due to the other system supporting mode optimisation, where the data can be split into chunks, each with a different encoding mode, for example if my URL contains https://www.example.com/ABC1234567890/XYZ, this could be encoded as a byte-mode chunk of https://www.example.com followed by an alphanumeric chunk of /ABC1234567890/XYZ, or possibly even finer chunks if 1234567890 could be dropped to numeric mode.

    This page has an excellent demonstration of mode optimization along with a detailed description of how it works.

    Do you have any plans to implement this optimisation so we can have smaller QRs?

    opened by Synchro 0
Releases(2.0.7)
  • 2.0.7(Mar 14, 2022)

  • 2.0.6(Feb 4, 2022)

  • 2.0.5(Jan 31, 2022)

  • 2.0.0(Apr 25, 2018)

    Added

    • #25 allows for setting a more compact text output

    • CHANGELOG.md added (how meta)

    • Allows more complex shapes for modules

    • Allows setting a gradient for the foreground

    • Allows transparent backgrounds and alpha channel on all colors

    Changed

    • Minimum PHP version changed to 7.1

    • Imagick renderer now allows setting different output formats

    • New optimized SVG renderer

    Deprecated

    • Nothing.

    Removed

    • Legacy ZF module support removed

    Fixed

    • Non-release files are excluded from composer packages
    Source code(tar.gz)
    Source code(zip)
Owner
Bacon
Bacon
ImageWorkshop is a PHP5.3+ library that helps you to manage images based on GD library

================================ ImageWorkshop class ================================ Summary and features Really flexible and easy-to-use PHP class t

Clément Guillemain 853 Dec 27, 2022
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Piotr Śliwa 879 Dec 30, 2022
PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

PEL: PHP Exif Library README file for PEL: PHP Exif Library. A library with support for reading and writing Exif headers in JPEG and TIFF images using

null 264 Dec 4, 2022
QR Code Generator

QR Code By endroid If you like my work you can show appreciation by sponsoring via Github Sponsors or send me some ADA at DdzFFzCqrhszSwiFWMBQomfv6mkD

Jeroen van den Enden 3.9k Dec 30, 2022
An unofficial package maintained by Salla to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing

ZATCA (Fatoora) QR-Code Implementation An unofficial package maintained by Salla to help developers to implement ZATCA (Fatoora) QR code easily which

Salla 96 Dec 25, 2022
With the help of QR code technologies, digital entry passes can be created, which a user can show at the entry point to pass the door.

Navratri_Entry With the help of QR code technologies, digital entry passes can be created, which a user can show at the entry point to pass the door.

Kushang Shah 5 Aug 7, 2022
Laravel package a helper to Generate the QR code and signed it for ZATCA E-invoicing

Laravel ZATCA E-invoicing Introduction Laravel package a helper to Generate the QR code and signed it for ZATCA E-invoicing Installation To get the la

Ayman Alaiwah 8 Aug 17, 2022
EPC-QR-Code - REDAXO-Addon für GiroCode-kompatible EPC-QR-Codes

Generiert QR-Codes, die von GiroCode®️ kompatiblen Banking-Apps in einer Überweisung genutzt werden können.

alex+ Informationsdesign 4 Apr 12, 2022
PHP 5.3 Object Oriented image manipulation library

Imagine Tweet about it using the #php_imagine hashtag. Image manipulation library for PHP 5.3 inspired by Python's PIL and other image libraries. Requ

Bulat Shakirzyanov 4.3k Jan 6, 2023
Wonderfully easy on-demand image manipulation library with an HTTP based API.

Glide Glide is a wonderfully easy on-demand image manipulation library written in PHP. Its straightforward API is exposed via HTTP, similar to cloud i

The League of Extraordinary Packages 2.4k Dec 19, 2022
PHP Captcha library

Captcha Installation With composer : { ... "require": { "gregwar/captcha": "1.*" } } Usage You can create a captcha with the Captc

Grégoire Passault 1.6k Dec 25, 2022
A library using PHP to generate QRCode from https://www.qrcode-monkey.com free

PHP Class Generate Free QRCode ?? A library using PHP to generate QRCode from https://www.qrcode-monkey.com free ✋ NOTE: Do not generate too many QRCo

Nguyen Truong Nguyen 53 Dec 28, 2022
PHP library to resize, scale and crop images.

PHP library to resize, scale and crop images.

Gumlet 1.1k Jan 3, 2023
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

PHP Image Editor PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options ! ✨ Supporting ⭐ Star this repos

Franck Alary 17 Nov 13, 2022
Symfony Bundle to assist in imagine manipulation using the imagine library

LiipImagineBundle PHPUnit PHP-CS-Fixer Coverage Downloads Release This bundle provides an image manipulation abstraction toolkit for Symfony-based pro

Liip 1.6k Dec 30, 2022
Goldbach Algorithms Mask is a PHP library developed for Symfony for apply a mask to strings.

Goldbach Algorithms Mask (fondly nicknamed GoldMask) is a PHP library developed for Symfony for apply a mask to strings.

Goldbach Algorithms 1 Oct 30, 2021
PHPExif is a library which gives you easy access to the EXIF meta-data of an image

PHPExif v0.6.4 PHPExif is a library which gives you easy access to the EXIF meta-data of an image. PHPExif serves as a wrapper around some native or C

null 135 Dec 4, 2022
PEL: PHP Exif Library

PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

null 264 Dec 4, 2022