mirror of
https://github.com/ColonelParrot/jscanify.git
synced 2025-12-30 22:31:52 +00:00
extractPaper: remove callback, direct return
This commit is contained in:
parent
4a6c9964e9
commit
03e7e6932a
@ -1,4 +1,4 @@
|
||||
/*! jscanify v1.1.0 | (c) ColonelParrot and other contributors | MIT License */
|
||||
/*! jscanify v1.2.0 | (c) ColonelParrot and other contributors | MIT License */
|
||||
|
||||
const { Canvas, createCanvas, Image, ImageData } = require("canvas");
|
||||
const { JSDOM } = require("jsdom");
|
||||
@ -143,7 +143,7 @@ class jscanify {
|
||||
* @param {*} onComplete callback with `HTMLCanvasElement` passed - the unwarped paper
|
||||
* @param {*} cornerPoints optional custom corner points, in case automatic corner points are incorrect
|
||||
*/
|
||||
extractPaper(image, resultWidth, resultHeight, onComplete, cornerPoints) {
|
||||
extractPaper(image, resultWidth, resultHeight, cornerPoints) {
|
||||
const canvas = createCanvas();
|
||||
const img = cv.imread(image);
|
||||
const maxContour = this.findPaperContour(img);
|
||||
@ -190,7 +190,7 @@ class jscanify {
|
||||
|
||||
img.delete();
|
||||
warpedDst.delete();
|
||||
onComplete(canvas);
|
||||
return canvas;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*! jscanify v1.1.0 | (c) ColonelParrot and other contributors | MIT License */
|
||||
/*! jscanify v1.2.0 | (c) ColonelParrot and other contributors | MIT License */
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === "object" && typeof module !== "undefined"
|
||||
@ -134,7 +134,7 @@
|
||||
* @param {*} onComplete callback with `HTMLCanvasElement` passed - the unwarped paper
|
||||
* @param {*} cornerPoints optional custom corner points, in case automatic corner points are incorrect
|
||||
*/
|
||||
extractPaper(image, resultWidth, resultHeight, onComplete, cornerPoints) {
|
||||
extractPaper(image, resultWidth, resultHeight, cornerPoints) {
|
||||
const canvas = document.createElement("canvas");
|
||||
|
||||
const img = cv.imread(image);
|
||||
@ -187,7 +187,7 @@
|
||||
|
||||
img.delete()
|
||||
warpedDst.delete()
|
||||
onComplete(canvas)
|
||||
return canvas;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user