diff --git a/functions.js b/functions.js index 1858de6e..fcc848d4 100644 --- a/functions.js +++ b/functions.js @@ -1,5 +1,6 @@ import PDFLib from 'pdf-lib'; import PDFJS from "pdfjs-dist"; +import jsQR from "jsqr"; delete global.crypto; // TODO: I hate to do this, but the new node version forces me to, if anyone finds a better solution, please tell me! import * as pdfcpuWraopper from "./public/wasm/pdfcpu-wrapper-node.js"; @@ -58,5 +59,5 @@ export async function removeBlankPages(snapshot, whiteThreashold) { } export async function splitOn(snapshot, type, whiteThreashold) { - return dependantSplitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib); + return dependantSplitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib, jsQR); } \ No newline at end of file diff --git a/public/functions.js b/public/functions.js index 9a6870d0..2067e97e 100644 --- a/public/functions.js +++ b/public/functions.js @@ -1,7 +1,10 @@ // PDFLib gets importet via index.html script-tag -const OpenCV = { cv: cv } // OPENCV gets importet as cv via index.html script-tag // PDFJS as pdfjsLib via index.html script-tag +// TODO: import jsQR + + import * as pdfcpuWraopper from "./wasm/pdfcpu-wrapper-browser.js"; +const OpenCV = { cv: cv } // OPENCV gets importet as cv via index.html script-tag import { extractPages as dependantExtractPages } from "./functions/extractPages.js"; import { impose as dependantImpose } from './functions/impose.js'; @@ -56,5 +59,5 @@ export async function removeBlankPages(snapshot, whiteThreashold) { } export async function splitOn(snapshot, type, whiteThreashold) { - return dependantSplitOn(snapshot, type, whiteThreashold, pdfjsLib, OpenCV, PDFLib); + return dependantSplitOn(snapshot, type, whiteThreashold, pdfjsLib, OpenCV, PDFLib, jsQR); } \ No newline at end of file diff --git a/public/functions/splitOn.js b/public/functions/splitOn.js index e2d807aa..148fb106 100644 --- a/public/functions/splitOn.js +++ b/public/functions/splitOn.js @@ -1,8 +1,6 @@ import { detectEmptyPages } from "./shared/detectEmptyPages.js"; import { getImagesOnPage } from "./shared/getImagesOnPage.js"; -import jsQR from "jsQR"; - /** * @typedef {"BAR_CODE"|"QR_CODE"|"BLANK_PAGE"} SplitType */ @@ -16,7 +14,7 @@ import jsQR from "jsQR"; * @param {} PDFLib * @returns */ -export async function splitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib) { +export async function splitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib, jsQR) { let splitAtPages = []; @@ -70,7 +68,8 @@ export async function splitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PD async function checkForQROnImage(image) { console.log(image.data, image.width, image.height, image.width * image.height * 4); - // TODO: There is an issue with the jsQR package, and the package seems to be stale, we could create a fork and fix the issue (The package expects rgba but sometimes we have rgb). In the meanwhile we just force rgba: + // TODO: There is an issue with the jsQR package (The package expects rgba but sometimes we have rgb), and the package seems to be stale, we could create a fork and fix the issue. In the meanwhile we just force rgba: + // Check for rgb and convert to rgba if(image.data.length == image.width * image.height * 3) { const tmpArray = new Uint8ClampedArray(image.width * image.height * 4);