Closed realtebo closed 2 years ago
But the problem is that jpeg.decode give me an error about malformed data
This seems like the kind of thing you'd need to take up with the author of the jpeg decode library?
jsQR just needs an array of RGBA pixel values, so using jpeg.decode or such seems right to me, but I do not know why it would throw an error without knowing that code.
I found how to make it work
$image_file_content = base64_encode(file_get_contents( $filepath ));
$image_size = getimagesize( $filepath );
then I force js output passind data from php
const jpegData = Buffer.from("<?php echo $image_file_content ?>", 'base64');
const rawImageData = jpeg.decode(jpegData);
const clamped_array = Uint8ClampedArray.from(rawImageData.data);
const qr_code_text = window.jsQR(
clamped_array,
<?php echo $image_size[0]; ?>,
<?php echo $image_size[1]; ?>
);
After then I can use qr_code_text su decode an european green pass
const greenpassBody = qr_code_text.trim().substr(4);
const decodedData = base45.decode(greenpassBody);
const deflatedData = pako.inflate(decodedData);
const decodedGreenPassaData = cbor.decodeAllSync(deflatedData);
const decodedGreenPassDataValue = decodedGreenPassaData[0].value;
[headers1, headers2, cbor_data, signature] = decodedGreenPassDataValue;
const greenpassData = cbor.decodeAllSync(cbor_data);
... and ... yes.. this requires a lot of different packages. I used browserify to make it work in a browser
I am reading a file content using php
I tried to pass data to js-side using this
But the problem is that
jpeg.decode
give me an error about malformed dataI logged
jpegData
I ask you kindly what transformation to to my file data [a valid jpg] to be scanned client-side from your library.