Skip to content
Snippets Groups Projects
Commit 2995dbc9 authored by Boyan Tsolov's avatar Boyan Tsolov
Browse files

test 123a

parent a2a11202
No related branches found
No related tags found
1 merge request!91DRAFT: TEST (delete when done testing) upgrade yarn
Pipeline #68507 passed
...@@ -188,8 +188,10 @@ const generateNodeJSQrCode = (defaultOptions, qrCodeOptions, templateOptions) => ...@@ -188,8 +188,10 @@ const generateNodeJSQrCode = (defaultOptions, qrCodeOptions, templateOptions) =>
const QRCodeNodeJS = yield Promise.resolve().then(() => __importStar(require("easyqrcodejs-nodejs"))); const QRCodeNodeJS = yield Promise.resolve().then(() => __importStar(require("easyqrcodejs-nodejs")));
defaultOptions["correctLevel"] = defaultOptions["correctLevel"] =
QRCodeNodeJS.CorrectLevel[qrCodeOptions.correctionLevel]; // L, M, Q, H QRCodeNodeJS.CorrectLevel[qrCodeOptions.correctionLevel]; // L, M, Q, H
console.log('===00000000====', defaultOptions);
const qrcode = new QRCodeNodeJS.default(defaultOptions); const qrcode = new QRCodeNodeJS.default(defaultOptions);
const dataUrl = yield qrcode.toDataURL(); const dataUrl = yield qrcode.toDataURL();
console.log('///////////qrdata url////', dataUrl);
yield new Promise((resolve) => setTimeout(resolve, 10)); yield new Promise((resolve) => setTimeout(resolve, 10));
return yield putQrCodeOnChromakeyTemplateNodeJS(dataUrl, templateOptions.src, templateOptions.placeholderSize, templateOptions.placeholderSize); return yield putQrCodeOnChromakeyTemplateNodeJS(dataUrl, templateOptions.src, templateOptions.placeholderSize, templateOptions.placeholderSize);
}); });
...@@ -224,13 +226,13 @@ const putQrCodeOnChromakeyTemplateNodeJS = (qrCodeImageBase64, templateImageBase ...@@ -224,13 +226,13 @@ const putQrCodeOnChromakeyTemplateNodeJS = (qrCodeImageBase64, templateImageBase
throw new Error("NodeJS cannot load qr code image"); throw new Error("NodeJS cannot load qr code image");
} }
const templateImage = yield loadImageNode(templateImageBase64, document); const templateImage = yield loadImageNode(templateImageBase64, document);
console.log('==11==11111111====', templateImage.width); console.log("==11==11111111====", templateImage.width);
if (templateImage.width < placeholderWidth || if (templateImage.width < placeholderWidth ||
templateImage.height < placeholderHeight) { templateImage.height < placeholderHeight) {
throw new Error("Placeholder is bigger than image"); throw new Error("Placeholder is bigger than image");
} }
const templateCanvas = document.createElement("canvas"); const templateCanvas = document.createElement("canvas");
console.log('===2222TEmplateCanvas===', templateCanvas.width); console.log("===2222TEmplateCanvas===", templateCanvas.width);
templateCanvas.width = templateImage.width; templateCanvas.width = templateImage.width;
templateCanvas.height = templateImage.height; templateCanvas.height = templateImage.height;
const templateCtx = templateCanvas.getContext("2d"); const templateCtx = templateCanvas.getContext("2d");
...@@ -238,7 +240,7 @@ const putQrCodeOnChromakeyTemplateNodeJS = (qrCodeImageBase64, templateImageBase ...@@ -238,7 +240,7 @@ const putQrCodeOnChromakeyTemplateNodeJS = (qrCodeImageBase64, templateImageBase
const templateImgData = templateCtx.getImageData(0, 0, templateCanvas.width, templateCanvas.height); const templateImgData = templateCtx.getImageData(0, 0, templateCanvas.width, templateCanvas.height);
const placeholderCoordinates = findChromakeyBoundaries(templateImage.width, templateImage.height, templateImgData, placeholderWidth, placeholderHeight); const placeholderCoordinates = findChromakeyBoundaries(templateImage.width, templateImage.height, templateImgData, placeholderWidth, placeholderHeight);
// -2 is for QR to slightly cover borders. To avoid green mask bulging out // -2 is for QR to slightly cover borders. To avoid green mask bulging out
console.log('====33333333====qrCodeImage===', qrCodeImage.width); console.log("====33333333====qrCodeImage===", qrCodeImage.width);
const scaleX = ((qrCodeImage.width - 2) / placeholderWidth) * scale; const scaleX = ((qrCodeImage.width - 2) / placeholderWidth) * scale;
const scaleY = ((qrCodeImage.height - 2) / placeholderHeight) * scale; const scaleY = ((qrCodeImage.height - 2) / placeholderHeight) * scale;
qrCodeImage.width *= scale; qrCodeImage.width *= scale;
...@@ -246,7 +248,7 @@ const putQrCodeOnChromakeyTemplateNodeJS = (qrCodeImageBase64, templateImageBase ...@@ -246,7 +248,7 @@ const putQrCodeOnChromakeyTemplateNodeJS = (qrCodeImageBase64, templateImageBase
const bannerCanvas = document.createElement("canvas"); const bannerCanvas = document.createElement("canvas");
const scaledTemplateW = Math.floor(templateImage.width * scaleX); const scaledTemplateW = Math.floor(templateImage.width * scaleX);
const scaledTemplateH = Math.floor(templateImage.height * scaleY); const scaledTemplateH = Math.floor(templateImage.height * scaleY);
console.log('=====4444=====BannerCanvas==', bannerCanvas.width); console.log("=====4444=====BannerCanvas==", bannerCanvas.width);
bannerCanvas.width = scaledTemplateW; bannerCanvas.width = scaledTemplateW;
bannerCanvas.height = scaledTemplateH; bannerCanvas.height = scaledTemplateH;
const bannerCtx = bannerCanvas.getContext("2d"); const bannerCtx = bannerCanvas.getContext("2d");
......
...@@ -225,9 +225,14 @@ const generateNodeJSQrCode = async ( ...@@ -225,9 +225,14 @@ const generateNodeJSQrCode = async (
defaultOptions["correctLevel"] = defaultOptions["correctLevel"] =
QRCodeNodeJS.CorrectLevel[qrCodeOptions.correctionLevel]; // L, M, Q, H QRCodeNodeJS.CorrectLevel[qrCodeOptions.correctionLevel]; // L, M, Q, H
console.log("===00000000====", defaultOptions);
const qrcode = new QRCodeNodeJS.default(defaultOptions); const qrcode = new QRCodeNodeJS.default(defaultOptions);
const dataUrl = await qrcode.toDataURL(); const dataUrl = await qrcode.toDataURL();
console.log("///////////qrdata url////", dataUrl);
await new Promise((resolve) => setTimeout(resolve, 10)); await new Promise((resolve) => setTimeout(resolve, 10));
return await putQrCodeOnChromakeyTemplateNodeJS( return await putQrCodeOnChromakeyTemplateNodeJS(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment