macos-vision 0.1.1 → 0.1.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 CHANGED
@@ -22,7 +22,41 @@ npm install macos-vision
22
22
 
23
23
  The native Swift binary is compiled automatically on install.
24
24
 
25
- ## Usage
25
+ ## CLI
26
+
27
+ ```bash
28
+ # OCR — plain text (default)
29
+ npx macos-vision photo.jpg
30
+
31
+ # Structured OCR blocks with bounding boxes
32
+ npx macos-vision --blocks photo.jpg
33
+
34
+ # Detect faces
35
+ npx macos-vision --faces photo.jpg
36
+
37
+ # Detect barcodes and QR codes
38
+ npx macos-vision --barcodes photo.jpg
39
+
40
+ # Detect rectangular shapes
41
+ npx macos-vision --rectangles photo.jpg
42
+
43
+ # Find document boundary
44
+ npx macos-vision --document photo.jpg
45
+
46
+ # Classify image content
47
+ npx macos-vision --classify photo.jpg
48
+
49
+ # Run all detections at once
50
+ npx macos-vision --all photo.jpg
51
+ ```
52
+
53
+ Multiple flags can be combined: `npx macos-vision --blocks --faces --classify photo.jpg`
54
+
55
+ Structured results are printed as JSON to stdout.
56
+
57
+ ---
58
+
59
+ ## API
26
60
 
27
61
  ```js
28
62
  import { ocr, detectFaces, detectBarcodes, detectRectangles, detectDocument, classify } from 'macos-vision'
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ import { resolve, dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { ocr, detectFaces, detectBarcodes, detectRectangles, detectDocument, classify, } from './index.js';
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ const USAGE = `
7
+ Usage: vision-cli [options] <image>
8
+
9
+ Options:
10
+ --ocr OCR — plain text (default)
11
+ --blocks OCR — structured blocks with coordinates
12
+ --faces Face detection
13
+ --barcodes Barcode & QR code detection
14
+ --rectangles Rectangle detection
15
+ --document Document boundary detection
16
+ --classify Image classification
17
+ --all Run all of the above
18
+
19
+ --help Show this help
20
+
21
+ Examples:
22
+ vision-cli photo.jpg
23
+ vision-cli --blocks --faces photo.jpg
24
+ vision-cli --all photo.jpg
25
+ `.trim();
26
+ const rawArgs = process.argv.slice(2);
27
+ if (rawArgs.includes('--help') || rawArgs.length === 0) {
28
+ console.log(USAGE);
29
+ process.exit(0);
30
+ }
31
+ const flags = new Set(rawArgs.filter(a => a.startsWith('--')));
32
+ const fileArgs = rawArgs.filter(a => !a.startsWith('--'));
33
+ const imagePath = fileArgs[0] || resolve(__dirname, '../test/fixtures/sample.png');
34
+ const runAll = flags.has('--all');
35
+ const runOcr = runAll || flags.has('--ocr');
36
+ const runBlocks = runAll || flags.has('--blocks');
37
+ const runFaces = runAll || flags.has('--faces');
38
+ const runBarcodes = runAll || flags.has('--barcodes');
39
+ const runRects = runAll || flags.has('--rectangles');
40
+ const runDoc = runAll || flags.has('--document');
41
+ const runClassify = runAll || flags.has('--classify');
42
+ // Default: OCR text when no feature flag is given
43
+ const anyFeatureFlag = runAll || flags.has('--ocr') || flags.has('--blocks') ||
44
+ flags.has('--faces') || flags.has('--barcodes') || flags.has('--rectangles') ||
45
+ flags.has('--document') || flags.has('--classify');
46
+ const useDefault = !anyFeatureFlag;
47
+ async function main() {
48
+ try {
49
+ if (useDefault || runOcr) {
50
+ const text = await ocr(imagePath);
51
+ console.log(text);
52
+ }
53
+ if (runBlocks) {
54
+ const blocks = await ocr(imagePath, { format: 'blocks' });
55
+ console.log(JSON.stringify(blocks, null, 2));
56
+ }
57
+ if (runFaces) {
58
+ const faces = await detectFaces(imagePath);
59
+ console.log(JSON.stringify(faces, null, 2));
60
+ }
61
+ if (runBarcodes) {
62
+ const barcodes = await detectBarcodes(imagePath);
63
+ console.log(JSON.stringify(barcodes, null, 2));
64
+ }
65
+ if (runRects) {
66
+ const rectangles = await detectRectangles(imagePath);
67
+ console.log(JSON.stringify(rectangles, null, 2));
68
+ }
69
+ if (runDoc) {
70
+ const doc = await detectDocument(imagePath);
71
+ console.log(JSON.stringify(doc, null, 2));
72
+ }
73
+ if (runClassify) {
74
+ const labels = await classify(imagePath);
75
+ console.log(JSON.stringify(labels, null, 2));
76
+ }
77
+ }
78
+ catch (error) {
79
+ console.error('Error:', error);
80
+ process.exit(1);
81
+ }
82
+ }
83
+ main();
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "macos-vision",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Apple Vision OCR & image analysis for Node.js — native, fast, offline, no API keys",
5
5
  "author": "Adrian Wolczuk",
6
6
  "license": "MIT","type": "module",
7
7
  "main": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "bin": {
10
+ "macos-vision": "./dist/cli.js"
11
+ },
9
12
  "repository": {
10
13
  "type": "git",
11
14
  "url": "git+https://github.com/woladi/macos-vision.git"