scanic 0.1.5 → 0.1.7
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 +40 -10
- package/dist/scanic.js +324 -508
- package/dist/scanic.js.map +1 -1
- package/dist/scanic.umd.cjs +1 -1
- package/dist/scanic.umd.cjs.map +1 -1
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="#">
|
|
3
|
-
<img src="
|
|
3
|
+
<img src="public/scanic-logo-bg.png" alt="scanic logo" height="400">
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://npmjs.com/package/scanic"><img src="https://badgen.net/npm/dw/scanic"></a>
|
|
9
|
+
<br />
|
|
10
|
+
<a href="https://github.com/marquaye/scanic/blob/master/LICENSE"><img src="https://img.shields.io/github/license/marquaye/scanic.svg"></a>
|
|
11
|
+
<a href="https://npmjs.com/package/scanic"><img src="https://badgen.net/npm/v/scanic"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
7
14
|
# Scanic
|
|
8
15
|
|
|
9
16
|
**Modern Document Scanner for the Web**
|
|
@@ -12,7 +19,7 @@ Scanic is a blazing-fast, lightweight, and modern document scanner library writt
|
|
|
12
19
|
|
|
13
20
|
## Why Scanic?
|
|
14
21
|
|
|
15
|
-
I always wanted to use document scanning features within web environments for years. While OpenCV makes this easy, it comes at the cost of a 30+ MB download.
|
|
22
|
+
I always wanted to use document scanning features within web environments for years. While OpenCV makes this easy, it comes at the cost of a **30+ MB** download.
|
|
16
23
|
|
|
17
24
|
Scanic combines pure JavaScript algorithms with **Rust-compiled WebAssembly** for performance-critical operations like Gaussian blur, Canny edge detection, and gradient calculations. This hybrid approach delivers near-native performance while maintaining JavaScript's accessibility and a lightweight footprint.
|
|
18
25
|
|
|
@@ -48,7 +55,7 @@ Or use via CDN:
|
|
|
48
55
|
## Usage
|
|
49
56
|
|
|
50
57
|
```js
|
|
51
|
-
import { scanDocument,
|
|
58
|
+
import { scanDocument, extractDocument } from 'scanic';
|
|
52
59
|
|
|
53
60
|
// Simple usage - just detect document
|
|
54
61
|
const result = await scanDocument(imageElement);
|
|
@@ -56,11 +63,23 @@ if (result.success) {
|
|
|
56
63
|
console.log('Document found at corners:', result.corners);
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
// Extract the document (perspective correction)
|
|
66
|
+
// Extract the document (with perspective correction)
|
|
60
67
|
const extracted = await scanDocument(imageElement, { mode: 'extract' });
|
|
61
68
|
if (extracted.success) {
|
|
62
69
|
document.body.appendChild(extracted.output); // Display extracted document
|
|
63
70
|
}
|
|
71
|
+
|
|
72
|
+
// Manual extraction with custom corner points (for image editors)
|
|
73
|
+
const corners = {
|
|
74
|
+
topLeft: { x: 100, y: 50 },
|
|
75
|
+
topRight: { x: 400, y: 60 },
|
|
76
|
+
bottomRight: { x: 390, y: 300 },
|
|
77
|
+
bottomLeft: { x: 110, y: 290 }
|
|
78
|
+
};
|
|
79
|
+
const manualExtract = await extractDocument(imageElement, corners);
|
|
80
|
+
if (manualExtract.success) {
|
|
81
|
+
document.body.appendChild(manualExtract.output);
|
|
82
|
+
}
|
|
64
83
|
```
|
|
65
84
|
|
|
66
85
|
### Complete Example
|
|
@@ -104,7 +123,7 @@ async function processDocument() {
|
|
|
104
123
|
|
|
105
124
|
## API Reference
|
|
106
125
|
|
|
107
|
-
### Core
|
|
126
|
+
### Core Functions
|
|
108
127
|
|
|
109
128
|
#### `scanDocument(image, options?)`
|
|
110
129
|
Main entry point for document scanning with flexible modes and output options.
|
|
@@ -167,8 +186,22 @@ const rawData = await scanDocument(imageElement, {
|
|
|
167
186
|
mode: 'extract',
|
|
168
187
|
output: 'imagedata'
|
|
169
188
|
});
|
|
189
|
+
|
|
190
|
+
// Extract as DataURI
|
|
191
|
+
const rawData = await scanDocument(imageElement, {
|
|
192
|
+
mode: 'extract',
|
|
193
|
+
output: 'dataurl'
|
|
194
|
+
});
|
|
195
|
+
|
|
170
196
|
```
|
|
171
197
|
|
|
198
|
+
## Framework Examples
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
👉 **[Vue.js Example & Guide](docs/vue-example.md)**
|
|
202
|
+
|
|
203
|
+
👉 **[React Example & Guide](docs/react-example.md)**
|
|
204
|
+
|
|
172
205
|
|
|
173
206
|
## Development
|
|
174
207
|
|
|
@@ -243,10 +276,9 @@ Please ensure your code follows the existing style.
|
|
|
243
276
|
### 🏆 Gold Sponsors
|
|
244
277
|
|
|
245
278
|
<table>
|
|
246
|
-
<tr>
|
|
279
|
+
<tr style="color: black;">
|
|
247
280
|
<td align="center" width="300">
|
|
248
|
-
<a href="https://zeugnisprofi.com" target="_blank">
|
|
249
|
-
<img src="https://via.placeholder.com/200x80/4A90E2/FFFFFF?text=ZeugnisProfi" alt="ZeugnisProfi" width="200"/>
|
|
281
|
+
<a href="https://zeugnisprofi.com" target="_blank">
|
|
250
282
|
<br/>
|
|
251
283
|
<strong>ZeugnisProfi</strong>
|
|
252
284
|
</a>
|
|
@@ -255,7 +287,6 @@ Please ensure your code follows the existing style.
|
|
|
255
287
|
</td>
|
|
256
288
|
<td align="center" width="300">
|
|
257
289
|
<a href="https://zeugnisprofi.de" target="_blank">
|
|
258
|
-
<img src="https://via.placeholder.com/200x80/50C878/FFFFFF?text=ZeugnisProfi.de" alt="ZeugnisProfi.de" width="200"/>
|
|
259
290
|
<br/>
|
|
260
291
|
<strong>ZeugnisProfi.de</strong>
|
|
261
292
|
</a>
|
|
@@ -264,7 +295,6 @@ Please ensure your code follows the existing style.
|
|
|
264
295
|
</td>
|
|
265
296
|
<td align="center" width="250">
|
|
266
297
|
<a href="https://www.verlingo.de" target="_blank">
|
|
267
|
-
<img src="https://via.placeholder.com/180x70/FF6B35/FFFFFF?text=Verlingo" alt="Verlingo" width="180"/>
|
|
268
298
|
<br/>
|
|
269
299
|
<strong>Verlingo</strong>
|
|
270
300
|
</a>
|