jscanify 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -8
- package/docs/images/galaxy.webp +0 -0
- package/docs/images/github-explanation-long.png +0 -0
- package/docs/images/github-explanation.png +0 -0
- package/docs/images/logo-full-small.png +0 -0
- package/docs/images/logo-full.png +0 -0
- package/docs/images/logo-github.png +0 -0
- package/docs/index.css +1 -1
- package/docs/index.html +4 -4
- package/package.json +1 -1
- package/src/jscanify-node.js +13 -2
- package/src/jscanify.js +13 -5
- package/docs/images/galaxy.png +0 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="docs/images/logo-
|
|
2
|
+
<img src="docs/images/logo-github.png" height="150">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<a href="https://cdnjs.com/libraries/jscanify"><img src="https://img.shields.io/cdnjs/v/jscanify"></a>
|
|
8
8
|
<a href="https://npmjs.com/package/jscanify"><img src="https://badgen.net/npm/dw/jscanify"></a>
|
|
9
9
|
<br />
|
|
10
|
-
<a href="https://github.com/
|
|
10
|
+
<a href="https://github.com/puffinsoft/jscanify/blob/master/LICENSE"><img src="https://img.shields.io/github/license/puffinsoft/jscanify.svg"></a>
|
|
11
11
|
<a href="https://npmjs.com/package/jscanify"><img src="https://badgen.net/npm/v/jscanify"></a>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
18
|
<p align="center">
|
|
19
|
-
|
|
19
|
+
Powered with <a href="https://docs.opencv.org/3.4/d5/d10/tutorial_js_root.html">opencv.js</a><br/>
|
|
20
20
|
Supports the web, NodeJS, <a href="https://github.com/ColonelParrot/react-scanify-demo">React</a>, and others.
|
|
21
|
-
<br
|
|
21
|
+
<br/>
|
|
22
22
|
Available on <a href="https://www.npmjs.com/package/jscanify">npm</a> or via <a href="https://www.jsdelivr.com/package/gh/ColonelParrot/jscanify">cdn</a><br/>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
@@ -27,10 +27,20 @@ Available on <a href="https://www.npmjs.com/package/jscanify">npm</a> or via <a
|
|
|
27
27
|
- paper detection & highlighting
|
|
28
28
|
- paper scanning with distortion correction
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
> [!IMPORTANT]
|
|
31
|
+
> 🎉 _jscanify v1.3.0_ has just been released! **Same API, better results.** See the [release](https://github.com/puffinsoft/jscanify/releases/tag/v1.3.0) to see the difference! 🎉
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
- 🆕 glare suppression
|
|
35
|
+
- 🆕 multi-colored paper support
|
|
36
|
+
|
|
37
|
+
<hr />
|
|
38
|
+
|
|
39
|
+
<img src="docs/images/github-explanation-long.png" />
|
|
40
|
+
|
|
41
|
+
<h3 align="center" margin="0"><a href="https://github.com/puffinsoft/jscanify/wiki">➡️ view documentation</a></h3>
|
|
42
|
+
|
|
43
|
+
<hr/>
|
|
34
44
|
|
|
35
45
|
## Quickstart
|
|
36
46
|
|
|
@@ -116,3 +126,5 @@ To export the paper to a PDF, see [here](https://stackoverflow.com/questions/236
|
|
|
116
126
|
|
|
117
127
|
- for optimal paper detection, the paper should be placed on a flat surface with a solid background color
|
|
118
128
|
- we recommend wrapping your code using `jscanify` in a window `load` event listener to ensure OpenCV is loaded
|
|
129
|
+
|
|
130
|
+
<h3 align="center" margin="0"><a href="https://github.com/puffinsoft/jscanify/wiki">➡️ view documentation</a></h3>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/docs/index.css
CHANGED
package/docs/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
<body>
|
|
22
22
|
<div id="hero" style="position: relative">
|
|
23
|
-
<a href="https://github.com/
|
|
23
|
+
<a href="https://github.com/puffinsoft/jscanify" aria-label="View the library on GitHub" target="_blank" style="position: absolute; top: 0; right: 0">
|
|
24
24
|
<svg width="80" height="80" viewBox="0 0 250 250"
|
|
25
25
|
style="fill:white; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
|
|
26
26
|
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
fill="black" class="octo-body"></path>
|
|
33
33
|
</svg>
|
|
34
34
|
</a>
|
|
35
|
-
<img src="images/logo-full
|
|
36
|
-
<h2>
|
|
35
|
+
<img src="images/logo-full.png" alt="jscanify logo" style="height: 100px" />
|
|
36
|
+
<h2>the javascript document scanning library.</h2>
|
|
37
37
|
<br />
|
|
38
38
|
<div class="view-on">
|
|
39
|
-
<a class="view-on-option" href="https://github.com/
|
|
39
|
+
<a class="view-on-option" href="https://github.com/puffinsoft/jscanify" target="_blank" style="margin: 10px">
|
|
40
40
|
<svg width="16" height="16" aria-hidden="true" viewBox="0 0 16 16">
|
|
41
41
|
<path fill-rule="evenodd"
|
|
42
42
|
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z">
|
package/package.json
CHANGED
package/src/jscanify-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! jscanify v1.3.
|
|
1
|
+
/*! jscanify v1.3.3 | (c) ColonelParrot and other contributors | MIT License */
|
|
2
2
|
|
|
3
3
|
const { Canvas, createCanvas, Image, ImageData } = require("canvas");
|
|
4
4
|
const { JSDOM } = require("jsdom");
|
|
@@ -80,7 +80,10 @@ class jscanify {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
const maxContour =
|
|
83
|
+
const maxContour =
|
|
84
|
+
maxContourIndex >= 0 ?
|
|
85
|
+
contours.get(maxContourIndex) :
|
|
86
|
+
null;
|
|
84
87
|
|
|
85
88
|
imgGray.delete();
|
|
86
89
|
imgBlur.delete();
|
|
@@ -138,6 +141,9 @@ class jscanify {
|
|
|
138
141
|
|
|
139
142
|
/**
|
|
140
143
|
* Extracts and undistorts the image detected within the frame.
|
|
144
|
+
*
|
|
145
|
+
* Returns `null` if no paper is detected.
|
|
146
|
+
*
|
|
141
147
|
* @param {*} image image to process
|
|
142
148
|
* @param {*} resultWidth desired result paper width
|
|
143
149
|
* @param {*} resultHeight desired result paper height
|
|
@@ -148,6 +154,11 @@ class jscanify {
|
|
|
148
154
|
const canvas = createCanvas();
|
|
149
155
|
const img = cv.imread(image);
|
|
150
156
|
const maxContour = this.findPaperContour(img);
|
|
157
|
+
|
|
158
|
+
if(maxContour == null){
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
151
162
|
const {
|
|
152
163
|
topLeftCorner,
|
|
153
164
|
topRightCorner,
|
package/src/jscanify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! jscanify v1.3.
|
|
1
|
+
/*! jscanify v1.3.3 | (c) ColonelParrot and other contributors | MIT License */
|
|
2
2
|
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === "object" && typeof module !== "undefined"
|
|
@@ -71,7 +71,10 @@
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const maxContour =
|
|
74
|
+
const maxContour =
|
|
75
|
+
maxContourIndex >= 0 ?
|
|
76
|
+
contours.get(maxContourIndex) :
|
|
77
|
+
null;
|
|
75
78
|
|
|
76
79
|
imgGray.delete();
|
|
77
80
|
imgBlur.delete();
|
|
@@ -129,7 +132,10 @@
|
|
|
129
132
|
|
|
130
133
|
/**
|
|
131
134
|
* Extracts and undistorts the image detected within the frame.
|
|
132
|
-
*
|
|
135
|
+
*
|
|
136
|
+
* Returns `null` if no paper is detected.
|
|
137
|
+
*
|
|
138
|
+
* @param {*} image image to process
|
|
133
139
|
* @param {*} resultWidth desired result paper width
|
|
134
140
|
* @param {*} resultHeight desired result paper height
|
|
135
141
|
* @param {*} cornerPoints optional custom corner points, in case automatic corner points are incorrect
|
|
@@ -137,11 +143,13 @@
|
|
|
137
143
|
*/
|
|
138
144
|
extractPaper(image, resultWidth, resultHeight, cornerPoints) {
|
|
139
145
|
const canvas = document.createElement("canvas");
|
|
140
|
-
|
|
141
146
|
const img = cv.imread(image);
|
|
142
|
-
|
|
143
147
|
const maxContour = this.findPaperContour(img);
|
|
144
148
|
|
|
149
|
+
if(maxContour == null){
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
const {
|
|
146
154
|
topLeftCorner,
|
|
147
155
|
topRightCorner,
|
package/docs/images/galaxy.png
DELETED
|
Binary file
|