Replies: 5 comments 6 replies
-
Hi, first off: without the image producing that error I'm not in a position to help in any way. |
Beta Was this translation helpful? Give feedback.
-
Yes off course. Is there a way I could send it to you in a private way ? |
Beta Was this translation helpful? Give feedback.
-
My email address is in the file header of almost every file in this library.
I assume you mean before decoding? There's many things that you could do, first, the grayscale and contrast options, rotation, resizing (smaller QR Codes produce better results for some reason), perspective transform (tilt along the axes). Basically you could emulate the scanning of a mobile camera somewhat like this: while(true){
try{
// read qrcode ...
return $result;
}
catch(Throwable){
// apply transforms to image, continue, break after X retries maybe
}
} |
Beta Was this translation helpful? Give feedback.
-
I should add here that it's hard to estimate the correct directions for a perspective transform. Unlike a human, who looks at the output of the mobile camera's capturing input and who can position the QR Code in the app's view finder by tilting the camera in 3 axes, an algorithm here could only guess and try tilting the image back and forth a bit in hope to get a result. |
Beta Was this translation helpful? Give feedback.
-
Glad to be of help! Here's the resizing i tired in Imagemagick (for anyone else with a similar issue): $im = new Imagick(__DIR__.'/test-2000-a.png');
$im->resizeImage(
($im->getImageWidth() * 2),
($im->getImageHeight() * 2),
Imagick::FILTER_ROBIDOUXSHARP,
1.0,
);
$im->sharpenImage(3, 0.5);
// save intermediate image to check modifications
$im->writeImage(__DIR__.'/im_test.png');
$result = (new Decoder($options))->decode(new IMagickLuminanceSource($im, $options)); |
Beta Was this translation helpful? Give feedback.
-
Describe the bug or unexpected behaviour
A QRCode recognition fails with the error "failed to read version" even if the QRCode can be decoded with a phone for example.
Steps to reproduce the behavior
(new QRCode)->readFromFile($imagePath);
with
imagePath
being a good resolution jpg file.It fails in file
src/Decoder/BitMatrix.php
, line 345If you provide me with a way to send you the file privately or a way to track down the problem I would be happy to help. The QRCode contains personal information of someone else, so I cannot post the file in public here.
Environment (please complete the following information):
Beta Was this translation helpful? Give feedback.
All reactions