@sythos/js_barcode_universal 1.5.6 → 1.5.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 +13 -2
- package/bundle/sythos-barcode.esm.js +2 -2
- package/bundle/sythos-barcode.js +2 -2
- package/package.json +91 -25
- package/src/index.js +1 -1
- package/typings/aztec/decoder.d.ts +57 -0
- package/typings/aztec/detector.d.ts +62 -0
- package/typings/aztec/encoder.d.ts +94 -0
- package/typings/aztec/high-level.d.ts +89 -0
- package/typings/aztec/index.d.ts +35 -0
- package/typings/aztec/tables.d.ts +144 -0
- package/typings/aztecrune/decoder.d.ts +56 -0
- package/typings/aztecrune/detector.d.ts +53 -0
- package/typings/aztecrune/encoder.d.ts +51 -0
- package/typings/aztecrune/index.d.ts +35 -0
- package/typings/aztecrune/tables.d.ts +75 -0
- package/typings/bundle/sythos-barcode.d.ts +31 -0
- package/typings/bundle/sythos-barcode.esm.d.ts +31 -0
- package/typings/compactpdf417/decoder.d.ts +64 -0
- package/typings/compactpdf417/detector.d.ts +48 -0
- package/typings/compactpdf417/encoder.d.ts +49 -0
- package/typings/compactpdf417/index.d.ts +8 -0
- package/typings/compactpdf417/tables.d.ts +84 -0
- package/typings/core/bit-buffer.d.ts +78 -0
- package/typings/core/bit-matrix.d.ts +129 -0
- package/typings/core/errors.d.ts +57 -0
- package/typings/core/galois-field.d.ts +141 -0
- package/typings/core/index.d.ts +40 -0
- package/typings/core/reed-solomon.d.ts +65 -0
- package/typings/databar/codec.d.ts +78 -0
- package/typings/databar/decoder.d.ts +55 -0
- package/typings/databar/encoder.d.ts +34 -0
- package/typings/databar/gs1.d.ts +48 -0
- package/typings/databar/index.d.ts +37 -0
- package/typings/databar/patterns.d.ts +46 -0
- package/typings/databar/tables.d.ts +119 -0
- package/typings/datamatrix/decoder.d.ts +57 -0
- package/typings/datamatrix/detector.d.ts +59 -0
- package/typings/datamatrix/encoder.d.ts +36 -0
- package/typings/datamatrix/index.d.ts +35 -0
- package/typings/datamatrix/tables.d.ts +88 -0
- package/typings/frameqr/decoder.d.ts +64 -0
- package/typings/frameqr/detector.d.ts +96 -0
- package/typings/frameqr/encoder.d.ts +73 -0
- package/typings/frameqr/index.d.ts +34 -0
- package/typings/frameqr/tables.d.ts +123 -0
- package/typings/image/binarizer.d.ts +85 -0
- package/typings/image/grid-sampler.d.ts +82 -0
- package/typings/image/index.d.ts +39 -0
- package/typings/image/luminance.d.ts +112 -0
- package/typings/image/perspective.d.ts +111 -0
- package/typings/index.d.ts +363 -0
- package/typings/micropdf417/compaction.d.ts +38 -0
- package/typings/micropdf417/decoder.d.ts +57 -0
- package/typings/micropdf417/detector.d.ts +95 -0
- package/typings/micropdf417/encoder.d.ts +34 -0
- package/typings/micropdf417/error-correction.d.ts +38 -0
- package/typings/micropdf417/index.d.ts +36 -0
- package/typings/micropdf417/tables.d.ts +73 -0
- package/typings/microqr/decoder.d.ts +49 -0
- package/typings/microqr/detector.d.ts +96 -0
- package/typings/microqr/encoder.d.ts +33 -0
- package/typings/microqr/index.d.ts +35 -0
- package/typings/microqr/tables.d.ts +107 -0
- package/typings/oned/addons.d.ts +181 -0
- package/typings/oned/index.d.ts +55 -0
- package/typings/oned/patterns.d.ts +259 -0
- package/typings/oned/reader.d.ts +129 -0
- package/typings/oned/writers.d.ts +218 -0
- package/typings/pdf417/compaction.d.ts +59 -0
- package/typings/pdf417/decoder.d.ts +48 -0
- package/typings/pdf417/detector.d.ts +73 -0
- package/typings/pdf417/encoder.d.ts +32 -0
- package/typings/pdf417/error-correction.d.ts +34 -0
- package/typings/pdf417/index.d.ts +10 -0
- package/typings/pdf417/tables.d.ts +53 -0
- package/typings/qr/decoder.d.ts +79 -0
- package/typings/qr/detector.d.ts +93 -0
- package/typings/qr/encoder.d.ts +166 -0
- package/typings/qr/index.d.ts +43 -0
- package/typings/qr/tables.d.ts +291 -0
- package/typings/render/image-data.d.ts +58 -0
- package/typings/render/index.d.ts +110 -0
- package/typings/render/options.d.ts +98 -0
- package/typings/render/png.d.ts +58 -0
- package/typings/render/svg.d.ts +46 -0
- package/typings/render/webgl.d.ts +45 -0
- package/typings/render/webgpu.d.ts +51 -0
- package/typings/rmqr/decoder.d.ts +42 -0
- package/typings/rmqr/detector.d.ts +81 -0
- package/typings/rmqr/encoder.d.ts +45 -0
- package/typings/rmqr/index.d.ts +34 -0
- package/typings/rmqr/tables.d.ts +89 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/** @param {unknown} profile @returns {boolean} */
|
|
32
|
+
declare function isExpectedProfile(profile: unknown): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Decode a FrameQR Code matrix.
|
|
35
|
+
*
|
|
36
|
+
* @param {import('../core/bit-matrix.js').BitMatrix} matrix
|
|
37
|
+
* Square QR modules, normally returned by `encodeFrameQR` or a FrameQR
|
|
38
|
+
* detector. The encoder's `frameqr` metadata is required by default.
|
|
39
|
+
* @param {object} [options]
|
|
40
|
+
* @param {object} [options.canvas] Explicit canvas metadata for a sampled
|
|
41
|
+
* matrix when the source marker was not preserved.
|
|
42
|
+
* @param {string|object} [options.profile] Expected profile identifier.
|
|
43
|
+
* @param {boolean} [options.allowUnmarked=false] Explicit detector opt-in for
|
|
44
|
+
* a matrix whose marker was lost during image sampling.
|
|
45
|
+
* @returns {import('../qr/decoder.js').DecodeResult & {
|
|
46
|
+
* format: 'frameqr', profile: string, certified: false,
|
|
47
|
+
* frame: object, canvas: object, canvasDamage: object
|
|
48
|
+
* }}
|
|
49
|
+
* @throws {FormatError} If the profile marker/canvas is invalid or the input
|
|
50
|
+
* is an ordinary QR Code.
|
|
51
|
+
*/
|
|
52
|
+
export declare function decodeFrameQR(matrix: import('../core/bit-matrix.js').BitMatrix, options?: {
|
|
53
|
+
canvas?: object;
|
|
54
|
+
profile?: string | object;
|
|
55
|
+
allowUnmarked?: boolean;
|
|
56
|
+
}): import('../qr/decoder.js').DecodeResult & {
|
|
57
|
+
format: 'frameqr';
|
|
58
|
+
profile: string;
|
|
59
|
+
certified: false;
|
|
60
|
+
frame: object;
|
|
61
|
+
canvas: object;
|
|
62
|
+
canvasDamage: object;
|
|
63
|
+
};
|
|
64
|
+
export { isExpectedProfile };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
import type { BitMatrix } from '../core/bit-matrix.js';
|
|
32
|
+
export type Point = {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
};
|
|
36
|
+
export type FrameQRDetection = {
|
|
37
|
+
/**
|
|
38
|
+
* Outer corners in reading order.
|
|
39
|
+
*/
|
|
40
|
+
corners: Point[];
|
|
41
|
+
/**
|
|
42
|
+
* QR modules per side.
|
|
43
|
+
*/
|
|
44
|
+
dimension: number;
|
|
45
|
+
/**
|
|
46
|
+
* QR Model 2 version.
|
|
47
|
+
*/
|
|
48
|
+
version: number;
|
|
49
|
+
/**
|
|
50
|
+
* Estimated pixels per module.
|
|
51
|
+
*/
|
|
52
|
+
moduleSize: number;
|
|
53
|
+
/**
|
|
54
|
+
* Clockwise in-plane orientation in degrees.
|
|
55
|
+
*/
|
|
56
|
+
rotation: number;
|
|
57
|
+
/**
|
|
58
|
+
* Rectified profile matrix.
|
|
59
|
+
*/
|
|
60
|
+
matrix: BitMatrix;
|
|
61
|
+
/**
|
|
62
|
+
* Normalized canvas specification.
|
|
63
|
+
*/
|
|
64
|
+
canvas: object;
|
|
65
|
+
/**
|
|
66
|
+
* Profile identifier.
|
|
67
|
+
*/
|
|
68
|
+
profile: string;
|
|
69
|
+
/**
|
|
70
|
+
* Always false for this implementation.
|
|
71
|
+
*/
|
|
72
|
+
certified: false;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Detect FrameQR Code symbols in a binarized raster.
|
|
76
|
+
*
|
|
77
|
+
* @param {import('../core/bit-matrix.js').BitMatrix} binaryImage Set bit = dark.
|
|
78
|
+
* @param {object} [options]
|
|
79
|
+
* @param {object} [options.canvas] Explicit canvas metadata for non-default
|
|
80
|
+
* shapes/size. Without it, the profile's canonical centered square is used.
|
|
81
|
+
* @param {boolean} [options.voting=false] Use majority sampling per module.
|
|
82
|
+
* @returns {FrameQRDetection[]} Best candidate first; empty when no verified
|
|
83
|
+
* profile signature is found.
|
|
84
|
+
*/
|
|
85
|
+
export declare function detectFrameQR(binaryImage: import('../core/bit-matrix.js').BitMatrix, options?: {
|
|
86
|
+
canvas?: object;
|
|
87
|
+
voting?: boolean;
|
|
88
|
+
}): FrameQRDetection[];
|
|
89
|
+
/**
|
|
90
|
+
* Detect and decode all verified Canvas QR symbols in one call.
|
|
91
|
+
*
|
|
92
|
+
* @param {import('../core/bit-matrix.js').BitMatrix} binaryImage
|
|
93
|
+
* @param {object} [options]
|
|
94
|
+
* @returns {Array<object>}
|
|
95
|
+
*/
|
|
96
|
+
export declare function detectAndDecodeFrameQR(binaryImage: import('../core/bit-matrix.js').BitMatrix, options?: object): Array<object>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
export type FrameQrEncodeOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* The profile always uses QR error correction H.
|
|
34
|
+
*/
|
|
35
|
+
ecc?: 'H';
|
|
36
|
+
/**
|
|
37
|
+
* Force a QR version 1-40.
|
|
38
|
+
*/
|
|
39
|
+
version?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Force a QR mask 0-7.
|
|
42
|
+
*/
|
|
43
|
+
mask?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Byte mode interpretation.
|
|
46
|
+
*/
|
|
47
|
+
charset?: 'auto' | 'utf-8' | 'iso-8859-1';
|
|
48
|
+
/**
|
|
49
|
+
* Allow QR kanji mode.
|
|
50
|
+
*/
|
|
51
|
+
kanji?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Profile artwork reservation.
|
|
54
|
+
*/
|
|
55
|
+
canvas?: object;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Encode a QR Code with a conservative artwork canvas according to the
|
|
59
|
+
* non-certified FrameQR Code profile.
|
|
60
|
+
*
|
|
61
|
+
* The profile forces QR H error correction and rejects a canvas whenever its
|
|
62
|
+
* known codeword damage exceeds the per-block correction budget. When a
|
|
63
|
+
* version is not forced, the smallest QR version that holds both payload and
|
|
64
|
+
* safe canvas is selected. A decoder can reconstruct the reserved modules from
|
|
65
|
+
* the returned profile metadata.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} text
|
|
68
|
+
* @param {FrameQrEncodeOptions} [options]
|
|
69
|
+
* @returns {import('../core/bit-matrix.js').BitMatrix}
|
|
70
|
+
* @throws {EncodeError} When the QR payload/options are invalid or the canvas
|
|
71
|
+
* cannot safely fit the selected QR version.
|
|
72
|
+
*/
|
|
73
|
+
export declare function encodeFrameQR(text: string, options?: FrameQrEncodeOptions): import('../core/bit-matrix.js').BitMatrix;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
export { encodeFrameQR } from './encoder.js';
|
|
32
|
+
export { decodeFrameQR } from './decoder.js';
|
|
33
|
+
export { detectFrameQR, detectAndDecodeFrameQR } from './detector.js';
|
|
34
|
+
export { FRAMEQR_PROFILE, FRAMEQR_CANVAS_SHAPES, canvasModules, normalizeCanvasSpec, analyzeCanvasDamage, validateCanvasSpec, validateFrameQrTables, } from './tables.js';
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
* in the Software without restriction, including without limitation the rights
|
|
12
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
* furnished to do so, subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
* SOFTWARE.
|
|
26
|
+
*
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/** Public identity and compatibility boundary of the implementable profile. */
|
|
32
|
+
export declare const FRAMEQR_PROFILE: Readonly<{
|
|
33
|
+
id: "sythos-canvas-qr/1";
|
|
34
|
+
name: "FrameQR Code";
|
|
35
|
+
certified: false;
|
|
36
|
+
densoFrameQrCompatible: false;
|
|
37
|
+
baseSymbology: "QR Code Model 2";
|
|
38
|
+
requiredEcc: "H";
|
|
39
|
+
standard: "ISO/IEC 18004 QR Code baseline";
|
|
40
|
+
}>;
|
|
41
|
+
/** Canvas shapes whose module membership is fully deterministic. */
|
|
42
|
+
export declare const FRAMEQR_CANVAS_SHAPES: readonly string[];
|
|
43
|
+
/**
|
|
44
|
+
* Canonicalise a canvas request.
|
|
45
|
+
*
|
|
46
|
+
* Coordinates and dimensions are module units. Odd dimensions make the centre
|
|
47
|
+
* unambiguous. Only quarter turns are accepted because arbitrary-angle raster
|
|
48
|
+
* membership would depend on renderer-specific sampling.
|
|
49
|
+
*
|
|
50
|
+
* @param {number} symbolSize QR module width/height (21..177).
|
|
51
|
+
* @param {object} [canvas]
|
|
52
|
+
* @returns {{shape:string,centerX:number,centerY:number,width:number,height:number,angle:number}}
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizeCanvasSpec(symbolSize: number, canvas?: object): {
|
|
55
|
+
shape: string;
|
|
56
|
+
centerX: number;
|
|
57
|
+
centerY: number;
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
angle: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Enumerate canvas modules, including any overlaps with QR function modules.
|
|
64
|
+
* A conforming encoder rejects such overlaps rather than damaging function
|
|
65
|
+
* patterns.
|
|
66
|
+
*
|
|
67
|
+
* @param {number} symbolSize
|
|
68
|
+
* @param {object} [canvas]
|
|
69
|
+
* @returns {Array<[number, number]>}
|
|
70
|
+
*/
|
|
71
|
+
export declare function canvasModules(symbolSize: number, canvas?: object): Array<[number, number]>;
|
|
72
|
+
/**
|
|
73
|
+
* Calculate worst-case QR codeword damage caused by a canvas.
|
|
74
|
+
* A codeword is counted if any of its modules is touched. This is conservative:
|
|
75
|
+
* clearing an already-light module does no damage, but safety cannot depend on
|
|
76
|
+
* one payload or mask.
|
|
77
|
+
*
|
|
78
|
+
* @param {number} version QR version 1..40.
|
|
79
|
+
* @param {object} [canvas]
|
|
80
|
+
*/
|
|
81
|
+
export declare function analyzeCanvasDamage(version: number, canvas?: object): {
|
|
82
|
+
profile: "sythos-canvas-qr/1";
|
|
83
|
+
certified: boolean;
|
|
84
|
+
version: number;
|
|
85
|
+
symbolSize: number;
|
|
86
|
+
canvas: {
|
|
87
|
+
shape: string;
|
|
88
|
+
centerX: number;
|
|
89
|
+
centerY: number;
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
angle: number;
|
|
93
|
+
};
|
|
94
|
+
canvasModuleCount: number;
|
|
95
|
+
reservedOverlaps: [number, number][];
|
|
96
|
+
touchedCodewordCount: number;
|
|
97
|
+
touchedCodewordsByBlock: number[];
|
|
98
|
+
correctionBudgetPerBlock: number;
|
|
99
|
+
safe: boolean;
|
|
100
|
+
};
|
|
101
|
+
/** Validate a canvas and return the non-certifying structural analysis. */
|
|
102
|
+
export declare function validateCanvasSpec(version: any, canvas?: {}): {
|
|
103
|
+
profile: "sythos-canvas-qr/1";
|
|
104
|
+
certified: boolean;
|
|
105
|
+
version: number;
|
|
106
|
+
symbolSize: number;
|
|
107
|
+
canvas: {
|
|
108
|
+
shape: string;
|
|
109
|
+
centerX: number;
|
|
110
|
+
centerY: number;
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
angle: number;
|
|
114
|
+
};
|
|
115
|
+
canvasModuleCount: number;
|
|
116
|
+
reservedOverlaps: [number, number][];
|
|
117
|
+
touchedCodewordCount: number;
|
|
118
|
+
touchedCodewordsByBlock: number[];
|
|
119
|
+
correctionBudgetPerBlock: number;
|
|
120
|
+
safe: boolean;
|
|
121
|
+
};
|
|
122
|
+
/** Self-check the fixed profile contract and representative QR geometries. */
|
|
123
|
+
export declare function validateFrameQrTables(): string[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Greyscale to black-and-white.
|
|
33
|
+
*
|
|
34
|
+
* This is the single biggest determinant of whether a reader works on real
|
|
35
|
+
* photographs. Decoding logic is exact and either right or wrong; binarization
|
|
36
|
+
* is a judgement call made a million times per image, and every downstream
|
|
37
|
+
* stage inherits its mistakes. A symbol lost here is lost permanently.
|
|
38
|
+
*
|
|
39
|
+
* Two strategies:
|
|
40
|
+
*
|
|
41
|
+
* global — one threshold for the whole image. Fast, and correct for clean
|
|
42
|
+
* synthetic images: screenshots, generated PNGs, flat scans.
|
|
43
|
+
* hybrid — a threshold per 8x8 block, smoothed across neighbours. Handles
|
|
44
|
+
* the uneven lighting that dominates camera input: shadows,
|
|
45
|
+
* glare, vignetting, a page curving away from the lens.
|
|
46
|
+
*
|
|
47
|
+
* @module image/binarizer
|
|
48
|
+
*/
|
|
49
|
+
import { BitMatrix } from '../core/bit-matrix.js';
|
|
50
|
+
/**
|
|
51
|
+
* One threshold for the entire image, chosen from the luminance histogram.
|
|
52
|
+
*
|
|
53
|
+
* Finds the two strongest peaks — ideally ink and paper — and cuts at the
|
|
54
|
+
* point of lowest population between them, weighted by distance so a narrow
|
|
55
|
+
* secondary peak does not drag the threshold onto a shoulder.
|
|
56
|
+
*
|
|
57
|
+
* @param {import('./luminance.js').LuminanceSource} source
|
|
58
|
+
* @returns {BitMatrix} Set bit = dark module.
|
|
59
|
+
*/
|
|
60
|
+
export declare function binarizeGlobal(source: import('./luminance.js').LuminanceSource): BitMatrix;
|
|
61
|
+
/**
|
|
62
|
+
* Locally adaptive thresholding.
|
|
63
|
+
*
|
|
64
|
+
* Per 8x8 block: compute min, max and mean. A block with real contrast gets
|
|
65
|
+
* its own mean as the threshold. A block that is flat is ambiguous on its own
|
|
66
|
+
* — solid paper and solid ink look identical from the inside — so it inherits
|
|
67
|
+
* from its neighbourhood, which is what stops large quiet zones from being
|
|
68
|
+
* speckled into noise.
|
|
69
|
+
*
|
|
70
|
+
* Thresholds are then averaged over a 5x5 block window, so lighting gradients
|
|
71
|
+
* are followed smoothly instead of producing visible block seams that the
|
|
72
|
+
* detectors would read as edges.
|
|
73
|
+
*
|
|
74
|
+
* @param {import('./luminance.js').LuminanceSource} source
|
|
75
|
+
* @returns {BitMatrix}
|
|
76
|
+
*/
|
|
77
|
+
export declare function binarizeHybrid(source: import('./luminance.js').LuminanceSource): BitMatrix;
|
|
78
|
+
/**
|
|
79
|
+
* Binarize with the named strategy.
|
|
80
|
+
*
|
|
81
|
+
* @param {import('./luminance.js').LuminanceSource} source
|
|
82
|
+
* @param {'global' | 'hybrid' | 'auto'} [strategy]
|
|
83
|
+
* @returns {BitMatrix}
|
|
84
|
+
*/
|
|
85
|
+
export declare function binarize(source: import('./luminance.js').LuminanceSource, strategy?: 'global' | 'hybrid' | 'auto'): BitMatrix;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Resample a distorted symbol in the image into an upright module grid.
|
|
33
|
+
*
|
|
34
|
+
* Given a transform that maps grid coordinates to image coordinates, this
|
|
35
|
+
* samples the centre of every module. Sampling centres rather than averaging
|
|
36
|
+
* whole cells is deliberate: module edges are where blur and bleed live, and
|
|
37
|
+
* including them turns a marginal symbol into an unreadable one.
|
|
38
|
+
*
|
|
39
|
+
* @module image/grid-sampler
|
|
40
|
+
*/
|
|
41
|
+
import { BitMatrix } from '../core/bit-matrix.js';
|
|
42
|
+
import { PerspectiveTransform } from './perspective.js';
|
|
43
|
+
/**
|
|
44
|
+
* Sample a `dimension` x `dimension` grid (or `width` x `height`).
|
|
45
|
+
*
|
|
46
|
+
* @param {BitMatrix} image Binarized source image.
|
|
47
|
+
* @param {number} width Modules across.
|
|
48
|
+
* @param {number} height Modules down.
|
|
49
|
+
* @param {PerspectiveTransform} transform Grid space -> image space.
|
|
50
|
+
* @returns {BitMatrix}
|
|
51
|
+
* @throws {NotFoundError} If the grid falls outside the image.
|
|
52
|
+
*/
|
|
53
|
+
export declare function sampleGrid(image: BitMatrix, width: number, height: number, transform: PerspectiveTransform): BitMatrix;
|
|
54
|
+
/**
|
|
55
|
+
* Sample with a 3x3 majority vote per module.
|
|
56
|
+
*
|
|
57
|
+
* Slower, and worth it when a single-point sample lands on a speck of noise or
|
|
58
|
+
* a JPEG artefact. Readers fall back to this after a clean sample fails to
|
|
59
|
+
* decode, rather than paying for it on every attempt.
|
|
60
|
+
*
|
|
61
|
+
* @param {BitMatrix} image
|
|
62
|
+
* @param {number} width
|
|
63
|
+
* @param {number} height
|
|
64
|
+
* @param {PerspectiveTransform} transform
|
|
65
|
+
* @returns {BitMatrix}
|
|
66
|
+
*/
|
|
67
|
+
export declare function sampleGridVoting(image: BitMatrix, width: number, height: number, transform: PerspectiveTransform): BitMatrix;
|
|
68
|
+
/**
|
|
69
|
+
* Build the transform for a symbol whose four corners are known, and sample it.
|
|
70
|
+
*
|
|
71
|
+
* Corners are in reading order: top-left, top-right, bottom-right, bottom-left.
|
|
72
|
+
*
|
|
73
|
+
* @param {BitMatrix} image
|
|
74
|
+
* @param {number} dimension Modules per side.
|
|
75
|
+
* @param {Array<{x: number, y: number}>} corners
|
|
76
|
+
* @param {boolean} [voting]
|
|
77
|
+
* @returns {BitMatrix}
|
|
78
|
+
*/
|
|
79
|
+
export declare function sampleQuad(image: BitMatrix, dimension: number, corners: Array<{
|
|
80
|
+
x: number;
|
|
81
|
+
y: number;
|
|
82
|
+
}>, voting?: boolean): BitMatrix;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Sythos Barcode Suite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2026 Sythos
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-FileCopyrightText: 2026 Sythos (https://www.sythos.net)
|
|
27
|
+
* SPDX-License-Identifier: MIT
|
|
28
|
+
*
|
|
29
|
+
* Original work. No code from any other barcode implementation.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Image pipeline, re-exported.
|
|
33
|
+
*
|
|
34
|
+
* @module image
|
|
35
|
+
*/
|
|
36
|
+
export { LuminanceSource } from './luminance.js';
|
|
37
|
+
export { binarize, binarizeGlobal, binarizeHybrid } from './binarizer.js';
|
|
38
|
+
export { PerspectiveTransform } from './perspective.js';
|
|
39
|
+
export { sampleGrid, sampleGridVoting, sampleQuad } from './grid-sampler.js';
|