simple-qrcode icon indicating copy to clipboard operation
simple-qrcode copied to clipboard

QR codes for URLs longer than 79 characters become bar codes

Open xman40100 opened this issue 4 years ago • 13 comments

At my work environment, we are using the latest version of Simple QRCode (4.2) with Laravel 7 and PHP 7.3. We are generating URLs that are longer than 79 characters, and at that point, the QR code malforms and kinda becomes a bar code (unless it's an intended feature, sorry lol, is there a toggle?).

Reproduction steps:

  1. Generate a URL that is longer than 79 characters, for example, a normal Google Search URL.
  2. Generate a QR Code inside a Blade template, using {!! QRCode::generate('text') !!}
  3. The QR code will generate itself as bar code.

Expected (generated using this website and putting the query as https://www.google.com/search?q=test+search&source=hp&ei=271xYKfDCIGXwbkP2KSe8AI): Expected generated code

Generated: Actual generated code

xman40100 avatar Apr 10 '21 15:04 xman40100

Hi, Any news on this one? Since yesterday I have the same issue. It's really strange because it was working fine before, and I did not change anything on the server.

petrosit avatar Apr 28 '21 07:04 petrosit

There is no news, but I'll gladly accept a PR that resolves this.

SimplyCorey avatar Apr 29 '21 11:04 SimplyCorey

Any clue where I could search for the issue / fix? What I don't understand why it stopped working on a system overnight.

petrosit avatar Apr 29 '21 13:04 petrosit

Not really. I'm confused on why it would start failing all of a sudden as no release has been created in this package or any dependencies when I took a look. When I find some time, I can look at this a little more.

SimplyCorey avatar Apr 30 '21 11:04 SimplyCorey

Alright, thanks. In the meantime use the following workaround: I'm using tinyurl service to shorten the URLs: function tinyurl($url) { return file_get_contents('http://tinyurl.com/api-create.php?url='.urlencode($url)); }

petrosit avatar Apr 30 '21 11:04 petrosit

Hi there there is any news about this issue? you code is perfect and very easy to use, but i'm facing the same error encoding large strings I think it is related also with the size and the correction error in some combination of these elements i got a image like barcode. Please any suggestion or workaround ( i cant use tiniurl) ? Thanks in advance Stefano

QXT2013 avatar Aug 12 '21 16:08 QXT2013

Is this the svg or png formatter?

SimplyCorey avatar Aug 22 '21 12:08 SimplyCorey

Is this the svg or png formatter?

It happens with both afaik

petrosit avatar Aug 24 '21 09:08 petrosit

I'm using it into a View

{!! QrCode::errorCorrection('L')->size(100)->generate("https://www.xxxx.yyy/qr/" .$user->serial_id); !!}

I have to use errorCorrection to L to avoid bars. It seems it's a stange combination between size strint lenght and errorCorrection

QXT2013 avatar Aug 24 '21 13:08 QXT2013

Is this the svg or png formatter?

I recall it being both, since trying to do it with any formatter didn't give me the desired result.

xman40100 avatar Aug 25 '21 03:08 xman40100

I set errorCorrection to L size 200x200 and 400x400 and it is broken

frizikk avatar Oct 29 '21 07:10 frizikk

I think this issue is no more exists , I tested it & it works fine with me using laravel 7 , and php 7.3

tes-QR2

omar-tammam avatar May 26 '22 17:05 omar-tammam

It looks like wrong scale parameters are applied to the first <g> tag inside SVG. For me it was transform="scale(2,162)". So scale has two parameters 2(scale-X) and 162(scale-Y) when it should have one parameter scale(2.162). My solution was to replace comma with dot in line 100 of SvgImageBackEnd.php sprintf('scale(%s)', str_replace(',','.',round($size, self::PRECISION)))

SBasher avatar Jun 21 '22 15:06 SBasher

Can't reproduce.

SimplyCorey avatar Apr 05 '23 18:04 SimplyCorey