khanamiryan / php-qrcode-detector-decoder Goto Github PK
View Code? Open in Web Editor NEWThis is a PHP library to detect and decode QR-codes. This is first and only QR code reader that works without extensions.
License: Apache License 2.0
This is a PHP library to detect and decode QR-codes. This is first and only QR code reader that works without extensions.
License: Apache License 2.0
i have install "khanamiryan"
But Class 'QrReader' not found
Please help me
I got a problem and it says
Warning: file_get_contents(test.png): failed to open stream: No such file or directory in D:\xxx\htdocs\test\vendor\khanamiryan\qrcode-detector-decoder\lib\QrReader.php on line 34
I put image files on D:\xxx\htdocs\test\vendor\khanamiryan\qrcode-detector-decoder\lib directory.
Any idea?
I am trying to decode QR code image which is photo or screenshot taken from mobile phone/computer , but getting blank response. In short it is not working from any type of photo taken from Mobile/Computer.
Please resolve my issue ASAP.
Thanks in advance
There are around 25 occurrences of throw new InvalidArgumentException
in the source code all of them within namespaced classes. So it should be throw new \InvalidArgumentException
! Or am I wrong with something?
See http://stackoverflow.com/a/22664893/22470
One of my error messages:
Fatal error: Class 'Zxing\Qrcode\Decoder\InvalidArgumentException' not found in /www/vendors/php-qrcode-detector-decoder/qrcode/decoder/Version.php on line 121
Fatal error: Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in /storage/emulated/0/htdocs/php-qrcode-detector-decoder-master/tests/QrReaderTest.php:7 Stack trace: #0 {main} thrown in /storage/emulated/0/htdocs/php-qrcode-detector-decoder-master/tests/QrReaderTest.php on line 7
This file can not be decoded with QrReader! it just returns (bool)false
. But the text encoded in the QR Code is w_537244_40
.
$QrReader = new QrReader('wrong.png');
echo $QrReader->text();
The correct result can be proved with the online Zxing.org encoder here. It returns:
Raw text w_537244_40
Raw bytes 40 27 75 f1 01 a1 93 d1 00 d7 cd 0c 00 ec 11 ec
Barcode format QR_CODE
Parsed Result Type TEXT
Parsed Result w_537244_40
图片如果使用相对路径就报错,使用绝对路径就502了
using same code as mentioned.
text(); //return decoded text from QR Code var_dump($text); ?>private $dataWidth =>
int(1021)
private $dataHeight =>
int(2459)
private $left =>
int(0)
private $top =>
int(0)
private $image =>
class Imagick#42 (0) {
}
private $width =>
int(1021)
private $height =>
int(2459)
}
class QrReader#41 (1) {
public $result =>
bool(false)
}
Any help on what is going wrong?
You cannot call "new QrReader('image.jpg')" because the class is not found. You need to add "Zxing" before it, like below:
$qrcode = new Zxing\QrReader('barcode.jpg');
Must be added "use Zxing\QrReader;"
The original library supports reading Aztec codes (2d), can we have support for that?
We have implemented this library and we realized that the issues we were having with not being able to read the QR code are related to the size of the images uploaded.
Since we are accessing the device camera we have limitations on reducing the file size easily. What's the best way to reduce the files sizes before decoding the image.
$ composer require -vvv khanamiryan/qrcode-detector-decoder
...
Downloading http://repo.packagist.org/p/provider-2019-04%2444b1950ccd1436493c71087c82e1d7a63231808704231e7b9b10debef51896c3.json
Following redirect (2) https://packagist.org/p/provider-2019-04%2444b1950ccd1436493c71087c82e1d7a63231808704231e7b9b10debef51896c3.json
Downloading https://packagist.org/p/provider-2019-04%2444b1950ccd1436493c71087c82e1d7a63231808704231e7b9b10debef51896c3.json
[Composer\Downloader\TransportException]
The "https://packagist.org/p/provider-2019-04%2444b1950ccd1436493c71087c82e1d7a63231808704231e7b9b10debef51896c3.json" file could not be downloaded (HT
TP/1.1 404 Not Found)
Exception trace:
() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Util/RemoteFilesystem.php:438
Composer\Util\RemoteFilesystem->get() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Util/RemoteFilesystem.php:876
Composer\Util\RemoteFilesystem->handleRedirect() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Util/RemoteFilesystem.php:428
Composer\Util\RemoteFilesystem->get() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Util/RemoteFilesystem.php:104
Composer\Util\RemoteFilesystem->getContents() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Repository/ComposerRepository.php:683
Composer\Repository\ComposerRepository->fetchFile() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Repository/ComposerRepository.php:595
Composer\Repository\ComposerRepository->loadProviderListings() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Repository/ComposerRepository.php:315
Composer\Repository\ComposerRepository->whatProvides() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/DependencyResolver/Pool.php:204
Composer\DependencyResolver\Pool->computeWhatProvides() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/DependencyResolver/Pool.php:193
Composer\DependencyResolver\Pool->whatProvides() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Package/Version/VersionSelector.php:52
Composer\Package\Version\VersionSelector->findBestCandidate() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Command/InitCommand.php:705
Composer\Command\InitCommand->findBestVersionAndNameForPackage() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Command/InitCommand.php:401
Composer\Command\InitCommand->determineRequirements() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Command/RequireCommand.php:136
Composer\Command\RequireCommand->execute() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Command/Command.php:245
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php:835
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php:185
Symfony\Component\Console\Application->doRun() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php:258
Composer\Console\Application->doRun() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/src/Composer/Console/Application.php:104
Composer\Console\Application->run() at phar:///usr/local/Cellar/composer/1.8.5/bin/composer/bin/composer:61
require() at /usr/local/Cellar/composer/1.8.5/bin/composer:24
require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
when decode , it tells "Class 'Zxing\Qrcode\Decoder\Version' not found"
I am getting a lot of undefined function fatal errors. As far as I know, the correct php function is array_fill. Any reason why it is using fill array here?
Fatal error: Uncaught Error: Call to undefined function Zxing\Common\fill_array()
The repository description states This is first and only QR code reader that works without extensions.
however this is false since this requires the GD Extension.
What's the correct way to include the package if not using Composer ?
I dont use yet ur lib, but one thing.... i used the camera of mobiles smartphones, to catch the QR Code and i input the file into a canvas..... I dont' know if this is possible, but its very nice if i can send (POST) the image into ur PHP and they answer me with the QRCode in text format... What do u thing about this ?
This is failing with an image of 113px (I've tried with 120px and 200px):
// $topLeft = [x: 255, y: 100]
// $topRight = [x: 204, y: 106.5]
// $bottomLeft = [x: 204, y: 61]
// $moduleSize = 3.7482654545842
// $tltrCentersDimension = 6
// $tlblCentersDimension = 12
// $dimension = 16
$dimension =(int) $this->computeDimension($topLeft, $topRight, $bottomLeft, $moduleSize);
// $dimension = 17
Version::getProvisionalVersionForDimension($dimension);
That raises an exception:
self::getVersionForNumber(($dimension - 17) / 4);
public static function getVersionForNumber($versionNumber)
{
if ($versionNumber < 1 || $versionNumber > 40) {
throw new \InvalidArgumentException();
}
What can I do to solve this problem?
1/ License inconsistency
In composer.json
"license": "MIT",
But most of files have
* Licensed under the Apache License, Version 2.0 (the "License");
Some files don't have LIcense headers
2/ LICENSE file missing
This is expected to allow downstream distribution
More information, see https://fedoraproject.org/wiki/Packaging:LicensingGuidelines?rd=Packaging/LicensingGuidelines#License_Text
Common licenses that require including their texts with all derivative works include ASL 2.0, EPL, BSD and MIT.
Per common best practice
BTW, according to composer.json, this is MIT
But some file have ASL 2.0 license headers
Need to be clarified.
qrcode-detector-decoder
exception 'yii\base\ErrorException' with message 'syntax error, unexpected ':', expecting ';' or '{'' in /vendor/khanamiryan/qrcode-detector-decoder/lib/QrReader.php:77 Stack trace: #0 [internal function]: yii\base\ErrorHandler->handleFatalError() #1 {main}
Hello, downloaded this project composer but i cant found example file so i made a test.php file on root folder and use sample code like this.
<?php
require __DIR__ . "/vendor/autoload.php";
$qrcode = new QrReader('path/to_image');
$text = $qrcode->text(); //return decoded text from QR Code
?>
After then i had this error message: "Fatal error: Class 'QrReader' not found"
Any souliton for this or is have an example php?
When i decode the qrcode,why report this error ? is image too large?
Hi,
I was trying to upload image captured by mobile (Android mobile 8 MP Camera) But Its not working then I tried that image from direct upload from desktop still not working. In short Its not working for QR code Image captured by mobile.
Please resolve my issue ASAP.
Thanks in advance
$path = strtolower(implode('/', $path));
$path = __DIR__ . '/lib/' . $path . '/' . $className . '.php';
All directories needs to be rename to lowercase if using bootstrap.php
.
I'm trying to use this library with a picture send by a form POST.
I don't want to save it to the server, and I want to use the temporary storage :
$qrScreenPath = $_FILES['file']['tmp_name'];
$qrcode = new Zxing\QrReader($qrScreenPath);
$text = $qrcode->text(); //return decoded text from QR Code
but I get this warning error :
imagecreatefromstring() : No JPEG support in this PHP build.
Does it a normal behavior of the library?
PS : I tried with a local picture, it works.
PHP 7
GD Library Enabled
I've been spending some large minutes until I found it should be:
$ composer require khanamiryan/qrcode-detector-decoder:dev-master
Otherwise it says no stable version found. I suppose that this will be happening until a release has been published in github.
Hello,
i started looking into this detector-decoder and it works really well for small images, the problem is once i get to bigger images,
i want to be able to find a QR code within an image, for example if someone is holding a QR code while having their photo taken.
is there an know memory problem when using big images?
thank you
Jamie
If so, how can get it?
Thank you and congratulations for your work.
now, many php projects support composer install, could you modify your code, and add such composer.json file.
thank you.
Use:
$qrcode = new QrReader($img);
$text = $qrcode->text();
var_dump($text);
Error:
[InvalidArgumentException] exception 'InvalidArgumentException' in Qrcode/Decoder/Version.php:121
Qrcode/Decoder/Version.php:121 ->
/**
*
Deduces version information purely from QR Code dimensions.
Hi khanamiryan,
I get a infinite loop with following message:
" Warning : Division by zero in C : \ xampp \ htdocs \ qrcodereader \ lib \ common \ customFunctions.php on line 18 "
The GD Library and PHP version > = 5.3 is installed.
I am doing something specific wrong?
Hello,
My dev and prod environment is Ubuntu 14.
Dev is running PHP 7.1.8-2+ubuntu14.04.1+deb.sury.org+4 while prod is running PHP 7.0.24-1+ubuntu14.04.1+deb.sury.org+1
This error is thrown in production but not in dev.
I had previously logged this issue in Usuario #207 (2amigos/yii2-usuario#207) because that project uses this as a dependency but it was closed so it can be properly logged here.
Could someone please review and comment, thanks
Hi I'm building a aplication fon transfer files using qr code but when i found your library, i notice that was missing to files and i fixed the bug there you have the files.
The location is : /lib/common/
->CharacterSetEci.php
->AbstractEnum.php
And replace your : /lib/QrReader.php
by mine, i just updated the include of the files.
fallow location whith the help: https://www.dropbox.com/s/uo1pvx8fhga8h9m/phpQrReader.pdf?dl=0
the new zip compilation -> https://www.dropbox.com/s/ig6rf33zabohp2g/phpQrDecoder.zip?dl=0
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /var/www/fairwarning_app/vendor/khanamiryan/qrcode-detector-decoder/lib/BinaryBitmap.php on line 77
Parse error: syntax error, unexpected '=' in /var/www/fairwarning_app/vendor/khanamiryan/qrcode-detector-decoder/lib/Qrcode/QRCodeReader.php on line 190
You have: [$x, $y] = $leftTopBlack;
Should be: list($x, $y) = $leftTopBlack;
My code:
`<?php
use Zxing\QrReader;
$qrcode = new QrReader('http://qrcoder.ru/code/?lalala&4&0');
$text = $qrcode->text(); //return decoded text from QR Code
echo $text;
I have error: Attempted to call function "imagecreatefromstring" from namespace "Zxing"
`
How to fix problem?
In version 1
the class QrReader
is in the root namespace. In version 1.0.1
it has moved to namespace Zxing
. The change was introduced in 4f4e165. Are you supporting semver (https://semver.org/)? It is the default for composer packages. If you do not use it, it might be worthwhile to include a statement about the policy followed in your readme.md
.
can this library read/scan multiple qrcodes in one image?
i want to use this library to read multiple image .
Could you create a new tag for a composer release?
Maybe 0.1.0
would be a good idea while the improvements from #21 are gradually included.
That way people can rely on 0.1.*
until they are ready to move to namespaces, etc in later versions
@khanamiryan hello, when i try install this plugin using composer with run this
composer require khanamiryan/qrcode-detector-decoder
I got error,
[InvalidArgumentException]
Could not find package khanamiryan/qrcode-detector-decoder at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability
How should i do?
Hello My Friend,
Thanks for sharing such a nice code base for qrcode. I am using this to decode some of my QR codes.
But it is not showing any decoded text for these QR images. Can you please help? I am attaching the QR code images. Though, I can decode your sample QR code image, It confirms that code is properly set.
I appreciate your help.
Look forward for your response.
Missing class 'QRCodeDecoderMetaData' in lib\Qrcode\Decoder\Decoder.php line 135, please advise me where this class is?
Fatal error: Class 'Zxing\Qrcode\Decoder\Version' not found in /var/www/fairwarning_app/vendor/khanamiryan/qrcode-detector-decoder/lib/Qrcode/Detector/Detector.php on line 84
It's right, this does not seem to exist at all.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.