mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-01-23 00:06:08 +01:00
Updated Imports
This commit is contained in:
parent
dd14b3a773
commit
013a3f7e1b
@ -1,5 +1,6 @@
|
|||||||
import PDFLib from 'pdf-lib';
|
import PDFLib from 'pdf-lib';
|
||||||
import PDFJS from "pdfjs-dist";
|
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!
|
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";
|
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) {
|
export async function splitOn(snapshot, type, whiteThreashold) {
|
||||||
return dependantSplitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib);
|
return dependantSplitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib, jsQR);
|
||||||
}
|
}
|
@ -1,7 +1,10 @@
|
|||||||
// PDFLib gets importet via index.html script-tag
|
// 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
|
// PDFJS as pdfjsLib via index.html script-tag
|
||||||
|
// TODO: import jsQR
|
||||||
|
|
||||||
|
|
||||||
import * as pdfcpuWraopper from "./wasm/pdfcpu-wrapper-browser.js";
|
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 { extractPages as dependantExtractPages } from "./functions/extractPages.js";
|
||||||
import { impose as dependantImpose } from './functions/impose.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) {
|
export async function splitOn(snapshot, type, whiteThreashold) {
|
||||||
return dependantSplitOn(snapshot, type, whiteThreashold, pdfjsLib, OpenCV, PDFLib);
|
return dependantSplitOn(snapshot, type, whiteThreashold, pdfjsLib, OpenCV, PDFLib, jsQR);
|
||||||
}
|
}
|
@ -1,8 +1,6 @@
|
|||||||
import { detectEmptyPages } from "./shared/detectEmptyPages.js";
|
import { detectEmptyPages } from "./shared/detectEmptyPages.js";
|
||||||
import { getImagesOnPage } from "./shared/getImagesOnPage.js";
|
import { getImagesOnPage } from "./shared/getImagesOnPage.js";
|
||||||
|
|
||||||
import jsQR from "jsQR";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {"BAR_CODE"|"QR_CODE"|"BLANK_PAGE"} SplitType
|
* @typedef {"BAR_CODE"|"QR_CODE"|"BLANK_PAGE"} SplitType
|
||||||
*/
|
*/
|
||||||
@ -16,7 +14,7 @@ import jsQR from "jsQR";
|
|||||||
* @param {} PDFLib
|
* @param {} PDFLib
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function splitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib) {
|
export async function splitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PDFLib, jsQR) {
|
||||||
|
|
||||||
let splitAtPages = [];
|
let splitAtPages = [];
|
||||||
|
|
||||||
@ -70,7 +68,8 @@ export async function splitOn(snapshot, type, whiteThreashold, PDFJS, OpenCV, PD
|
|||||||
async function checkForQROnImage(image) {
|
async function checkForQROnImage(image) {
|
||||||
console.log(image.data, image.width, image.height, image.width * image.height * 4);
|
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) {
|
if(image.data.length == image.width * image.height * 3) {
|
||||||
const tmpArray = new Uint8ClampedArray(image.width * image.height * 4);
|
const tmpArray = new Uint8ClampedArray(image.width * image.height * 4);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user