From 1135ca5fb4de6833befce1d52d9483d2b4fa91f2 Mon Sep 17 00:00:00 2001 From: j433866 Date: Tue, 2 Jul 2019 16:31:26 +0100 Subject: [PATCH] Remove duplicate function. Fix reading QR codes with transparent backgrounds --- src/core/Utils.mjs | 16 ---------------- src/core/lib/QRCode.mjs | 2 ++ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/core/Utils.mjs b/src/core/Utils.mjs index 6499e936..fed67553 100755 --- a/src/core/Utils.mjs +++ b/src/core/Utils.mjs @@ -594,22 +594,6 @@ class Utils { } - /** - * Converts a string to an ArrayBuffer. - * - * @param {string} string - */ - static strToArrayBuffer(string) { - const arrayBuffer = new ArrayBuffer(string.length * 2); - const arrayBufferView = new Uint8Array(arrayBuffer); - for (let i = 0; i < string.length; i++) { - arrayBufferView[i] = string.charCodeAt(i); - } - - return arrayBuffer; - } - - /** * Parses CSV data and returns it as a two dimensional array or strings. * diff --git a/src/core/lib/QRCode.mjs b/src/core/lib/QRCode.mjs index 709aafa2..93b60024 100644 --- a/src/core/lib/QRCode.mjs +++ b/src/core/lib/QRCode.mjs @@ -33,6 +33,8 @@ export async function parseQrCode(input, normalise) { image.background(0xFFFFFFFF); image.normalize(); image.greyscale(); + image = await image.getBufferAsync(jimp.MIME_JPEG); + image = await jimp.read(image); } } catch (err) { throw new OperationError(`Error normalising iamge. (${err})`);