djvu-rs 0.30.2 → 0.32.0

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
@@ -199,8 +199,13 @@ Layered `quality` / `archival` encodes default to fixed BT.601 thresholding.
199
199
  `--binarization sauvola` opts into adaptive local thresholding for mixed or
200
200
  uneven lighting; tune it with `--sauvola-window` and `--sauvola-k`.
201
201
  `--bg-inpaint` fills fully masked background blocks from neighbouring unmasked
202
- pixels, which can reduce dark boxes under heavy text strokes. These knobs are
203
- opt-in, only affect layered profiles, and do not change lossless JB2 defaults.
202
+ pixels, which can reduce dark boxes under heavy text strokes.
203
+ `--block-classify` routes photo and halftone blocks wholly to the background
204
+ layer instead of shredding them into mask speckle (mixed text+photo layouts);
205
+ pair it with `--adaptive-bg-subsample`, which densifies the background grid
206
+ where unmasked detail warrants it, so routed photos keep their detail. These
207
+ knobs are opt-in, only affect layered profiles, and do not change lossless
208
+ JB2 defaults.
204
209
  Library callers can use the same controls with `PageEncoder::with_segment_options`.
205
210
  For newly encoded pages, `PageEncoder::with_metadata` emits a `METz` chunk;
206
211
  for existing documents, `DjVuDocumentMut::page_mut(...).set_metadata(...)`
package/djvu_rs.d.ts CHANGED
@@ -23,16 +23,16 @@ export class WasmDocument {
23
23
  * Throws a JavaScript `Error` if the bytes are not a valid DjVu file.
24
24
  */
25
25
  static from_bytes(data: Uint8Array): WasmDocument;
26
+ /**
27
+ * Total number of pages in the document.
28
+ */
29
+ page_count(): number;
26
30
  /**
27
31
  * Return a handle to page `index` (0-based).
28
32
  *
29
33
  * Throws if `index >= page_count()`.
30
34
  */
31
35
  page(index: number): WasmPage;
32
- /**
33
- * Total number of pages in the document.
34
- */
35
- page_count(): number;
36
36
  /**
37
37
  * Render a contiguous batch of pages at `target_dpi`, returning one
38
38
  * [`WasmPixmap`] per page in input order (#610).
@@ -72,13 +72,6 @@ export class WasmPage {
72
72
  * Output height in pixels when rendered at `target_dpi`.
73
73
  */
74
74
  height_at(target_dpi: number): number;
75
- /**
76
- * Render the page at `target_dpi` and return raw RGBA pixels
77
- * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
78
- *
79
- * Throws on decode error.
80
- */
81
- render(target_dpi: number): Uint8ClampedArray;
82
75
  /**
83
76
  * Fast coarse render — decodes only the first BG44 chunk (~5 ms for a
84
77
  * typical color page).
@@ -91,6 +84,13 @@ export class WasmPage {
91
84
  * Throws on decode error.
92
85
  */
93
86
  render_coarse(target_dpi: number): Uint8ClampedArray | undefined;
87
+ /**
88
+ * Render the page at `target_dpi` and return raw RGBA pixels
89
+ * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
90
+ *
91
+ * Throws on decode error.
92
+ */
93
+ render(target_dpi: number): Uint8ClampedArray;
94
94
  /**
95
95
  * Render into a caller-owned [`WasmPixmap`], reusing its Rust-side
96
96
  * allocation (#611). No JS-side allocation, no wasm→JS copy — consume
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "djvu-rs",
3
3
  "type": "module",
4
4
  "description": "Read, render, convert, and create DjVu files. Pure-Rust DjVu decoder/encoder with CLI, WebAssembly, and Python bindings. DjVu to PDF, EPUB, TIFF, PNG, and text. MIT licensed, no GPL dependencies.",
5
- "version": "0.30.2",
5
+ "version": "0.32.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/scalar/README.md CHANGED
@@ -199,8 +199,13 @@ Layered `quality` / `archival` encodes default to fixed BT.601 thresholding.
199
199
  `--binarization sauvola` opts into adaptive local thresholding for mixed or
200
200
  uneven lighting; tune it with `--sauvola-window` and `--sauvola-k`.
201
201
  `--bg-inpaint` fills fully masked background blocks from neighbouring unmasked
202
- pixels, which can reduce dark boxes under heavy text strokes. These knobs are
203
- opt-in, only affect layered profiles, and do not change lossless JB2 defaults.
202
+ pixels, which can reduce dark boxes under heavy text strokes.
203
+ `--block-classify` routes photo and halftone blocks wholly to the background
204
+ layer instead of shredding them into mask speckle (mixed text+photo layouts);
205
+ pair it with `--adaptive-bg-subsample`, which densifies the background grid
206
+ where unmasked detail warrants it, so routed photos keep their detail. These
207
+ knobs are opt-in, only affect layered profiles, and do not change lossless
208
+ JB2 defaults.
204
209
  Library callers can use the same controls with `PageEncoder::with_segment_options`.
205
210
  For newly encoded pages, `PageEncoder::with_metadata` emits a `METz` chunk;
206
211
  for existing documents, `DjVuDocumentMut::page_mut(...).set_metadata(...)`
@@ -23,16 +23,16 @@ export class WasmDocument {
23
23
  * Throws a JavaScript `Error` if the bytes are not a valid DjVu file.
24
24
  */
25
25
  static from_bytes(data: Uint8Array): WasmDocument;
26
+ /**
27
+ * Total number of pages in the document.
28
+ */
29
+ page_count(): number;
26
30
  /**
27
31
  * Return a handle to page `index` (0-based).
28
32
  *
29
33
  * Throws if `index >= page_count()`.
30
34
  */
31
35
  page(index: number): WasmPage;
32
- /**
33
- * Total number of pages in the document.
34
- */
35
- page_count(): number;
36
36
  /**
37
37
  * Render a contiguous batch of pages at `target_dpi`, returning one
38
38
  * [`WasmPixmap`] per page in input order (#610).
@@ -72,13 +72,6 @@ export class WasmPage {
72
72
  * Output height in pixels when rendered at `target_dpi`.
73
73
  */
74
74
  height_at(target_dpi: number): number;
75
- /**
76
- * Render the page at `target_dpi` and return raw RGBA pixels
77
- * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
78
- *
79
- * Throws on decode error.
80
- */
81
- render(target_dpi: number): Uint8ClampedArray;
82
75
  /**
83
76
  * Fast coarse render — decodes only the first BG44 chunk (~5 ms for a
84
77
  * typical color page).
@@ -91,6 +84,13 @@ export class WasmPage {
91
84
  * Throws on decode error.
92
85
  */
93
86
  render_coarse(target_dpi: number): Uint8ClampedArray | undefined;
87
+ /**
88
+ * Render the page at `target_dpi` and return raw RGBA pixels
89
+ * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
90
+ *
91
+ * Throws on decode error.
92
+ */
93
+ render(target_dpi: number): Uint8ClampedArray;
94
94
  /**
95
95
  * Render into a caller-owned [`WasmPixmap`], reusing its Rust-side
96
96
  * allocation (#611). No JS-side allocation, no wasm→JS copy — consume
package/scalar/djvu_rs.js CHANGED
@@ -45,6 +45,14 @@ export class WasmDocument {
45
45
  }
46
46
  return WasmDocument.__wrap(ret[0]);
47
47
  }
48
+ /**
49
+ * Total number of pages in the document.
50
+ * @returns {number}
51
+ */
52
+ page_count() {
53
+ const ret = wasm.wasmdocument_page_count(this.__wbg_ptr);
54
+ return ret >>> 0;
55
+ }
48
56
  /**
49
57
  * Return a handle to page `index` (0-based).
50
58
  *
@@ -59,14 +67,6 @@ export class WasmDocument {
59
67
  }
60
68
  return WasmPage.__wrap(ret[0]);
61
69
  }
62
- /**
63
- * Total number of pages in the document.
64
- * @returns {number}
65
- */
66
- page_count() {
67
- const ret = wasm.wasmdocument_page_count(this.__wbg_ptr);
68
- return ret >>> 0;
69
- }
70
70
  /**
71
71
  * Render a contiguous batch of pages at `target_dpi`, returning one
72
72
  * [`WasmPixmap`] per page in input order (#610).
@@ -145,21 +145,6 @@ export class WasmPage {
145
145
  const ret = wasm.wasmpage_height_at(this.__wbg_ptr, target_dpi);
146
146
  return ret >>> 0;
147
147
  }
148
- /**
149
- * Render the page at `target_dpi` and return raw RGBA pixels
150
- * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
151
- *
152
- * Throws on decode error.
153
- * @param {number} target_dpi
154
- * @returns {Uint8ClampedArray}
155
- */
156
- render(target_dpi) {
157
- const ret = wasm.wasmpage_render(this.__wbg_ptr, target_dpi);
158
- if (ret[2]) {
159
- throw takeFromExternrefTable0(ret[1]);
160
- }
161
- return takeFromExternrefTable0(ret[0]);
162
- }
163
148
  /**
164
149
  * Fast coarse render — decodes only the first BG44 chunk (~5 ms for a
165
150
  * typical color page).
@@ -180,6 +165,21 @@ export class WasmPage {
180
165
  }
181
166
  return takeFromExternrefTable0(ret[0]);
182
167
  }
168
+ /**
169
+ * Render the page at `target_dpi` and return raw RGBA pixels
170
+ * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
171
+ *
172
+ * Throws on decode error.
173
+ * @param {number} target_dpi
174
+ * @returns {Uint8ClampedArray}
175
+ */
176
+ render(target_dpi) {
177
+ const ret = wasm.wasmpage_render(this.__wbg_ptr, target_dpi);
178
+ if (ret[2]) {
179
+ throw takeFromExternrefTable0(ret[1]);
180
+ }
181
+ return takeFromExternrefTable0(ret[0]);
182
+ }
183
183
  /**
184
184
  * Render into a caller-owned [`WasmPixmap`], reusing its Rust-side
185
185
  * allocation (#611). No JS-side allocation, no wasm→JS copy — consume
@@ -479,29 +479,29 @@ if (Symbol.dispose) WasmPixmap.prototype[Symbol.dispose] = WasmPixmap.prototype.
479
479
  function __wbg_get_imports() {
480
480
  const import0 = {
481
481
  __proto__: null,
482
- __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
482
+ __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
483
483
  const ret = Error(getStringFromWasm0(arg0, arg1));
484
484
  return ret;
485
485
  },
486
- __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
486
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
487
487
  throw new Error(getStringFromWasm0(arg0, arg1));
488
488
  },
489
- __wbg_length_13032799523c5735: function(arg0) {
489
+ __wbg_length_ff98c95d19109ba4: function(arg0) {
490
490
  const ret = arg0.length;
491
491
  return ret;
492
492
  },
493
- __wbg_new_with_length_5d351ffdb6e3397d: function(arg0) {
493
+ __wbg_new_with_length_ac9c609232fb2d1d: function(arg0) {
494
494
  const ret = new Uint8ClampedArray(arg0 >>> 0);
495
495
  return ret;
496
496
  },
497
- __wbg_set_5c15d3c5973de97a: function(arg0, arg1, arg2) {
497
+ __wbg_set_0488601468e80715: function(arg0, arg1, arg2) {
498
498
  arg0.set(getArrayU8FromWasm0(arg1, arg2));
499
499
  },
500
500
  __wbg_wasmpixmap_new: function(arg0) {
501
501
  const ret = WasmPixmap.__wrap(arg0);
502
502
  return ret;
503
503
  },
504
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
504
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
505
505
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8ClampedArray")`.
506
506
  const ret = getArrayU8FromWasm0(arg0, arg1);
507
507
  return ret;
Binary file
package/simd128/README.md CHANGED
@@ -199,8 +199,13 @@ Layered `quality` / `archival` encodes default to fixed BT.601 thresholding.
199
199
  `--binarization sauvola` opts into adaptive local thresholding for mixed or
200
200
  uneven lighting; tune it with `--sauvola-window` and `--sauvola-k`.
201
201
  `--bg-inpaint` fills fully masked background blocks from neighbouring unmasked
202
- pixels, which can reduce dark boxes under heavy text strokes. These knobs are
203
- opt-in, only affect layered profiles, and do not change lossless JB2 defaults.
202
+ pixels, which can reduce dark boxes under heavy text strokes.
203
+ `--block-classify` routes photo and halftone blocks wholly to the background
204
+ layer instead of shredding them into mask speckle (mixed text+photo layouts);
205
+ pair it with `--adaptive-bg-subsample`, which densifies the background grid
206
+ where unmasked detail warrants it, so routed photos keep their detail. These
207
+ knobs are opt-in, only affect layered profiles, and do not change lossless
208
+ JB2 defaults.
204
209
  Library callers can use the same controls with `PageEncoder::with_segment_options`.
205
210
  For newly encoded pages, `PageEncoder::with_metadata` emits a `METz` chunk;
206
211
  for existing documents, `DjVuDocumentMut::page_mut(...).set_metadata(...)`
@@ -23,16 +23,16 @@ export class WasmDocument {
23
23
  * Throws a JavaScript `Error` if the bytes are not a valid DjVu file.
24
24
  */
25
25
  static from_bytes(data: Uint8Array): WasmDocument;
26
+ /**
27
+ * Total number of pages in the document.
28
+ */
29
+ page_count(): number;
26
30
  /**
27
31
  * Return a handle to page `index` (0-based).
28
32
  *
29
33
  * Throws if `index >= page_count()`.
30
34
  */
31
35
  page(index: number): WasmPage;
32
- /**
33
- * Total number of pages in the document.
34
- */
35
- page_count(): number;
36
36
  /**
37
37
  * Render a contiguous batch of pages at `target_dpi`, returning one
38
38
  * [`WasmPixmap`] per page in input order (#610).
@@ -72,13 +72,6 @@ export class WasmPage {
72
72
  * Output height in pixels when rendered at `target_dpi`.
73
73
  */
74
74
  height_at(target_dpi: number): number;
75
- /**
76
- * Render the page at `target_dpi` and return raw RGBA pixels
77
- * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
78
- *
79
- * Throws on decode error.
80
- */
81
- render(target_dpi: number): Uint8ClampedArray;
82
75
  /**
83
76
  * Fast coarse render — decodes only the first BG44 chunk (~5 ms for a
84
77
  * typical color page).
@@ -91,6 +84,13 @@ export class WasmPage {
91
84
  * Throws on decode error.
92
85
  */
93
86
  render_coarse(target_dpi: number): Uint8ClampedArray | undefined;
87
+ /**
88
+ * Render the page at `target_dpi` and return raw RGBA pixels
89
+ * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
90
+ *
91
+ * Throws on decode error.
92
+ */
93
+ render(target_dpi: number): Uint8ClampedArray;
94
94
  /**
95
95
  * Render into a caller-owned [`WasmPixmap`], reusing its Rust-side
96
96
  * allocation (#611). No JS-side allocation, no wasm→JS copy — consume
@@ -45,6 +45,14 @@ export class WasmDocument {
45
45
  }
46
46
  return WasmDocument.__wrap(ret[0]);
47
47
  }
48
+ /**
49
+ * Total number of pages in the document.
50
+ * @returns {number}
51
+ */
52
+ page_count() {
53
+ const ret = wasm.wasmdocument_page_count(this.__wbg_ptr);
54
+ return ret >>> 0;
55
+ }
48
56
  /**
49
57
  * Return a handle to page `index` (0-based).
50
58
  *
@@ -59,14 +67,6 @@ export class WasmDocument {
59
67
  }
60
68
  return WasmPage.__wrap(ret[0]);
61
69
  }
62
- /**
63
- * Total number of pages in the document.
64
- * @returns {number}
65
- */
66
- page_count() {
67
- const ret = wasm.wasmdocument_page_count(this.__wbg_ptr);
68
- return ret >>> 0;
69
- }
70
70
  /**
71
71
  * Render a contiguous batch of pages at `target_dpi`, returning one
72
72
  * [`WasmPixmap`] per page in input order (#610).
@@ -145,21 +145,6 @@ export class WasmPage {
145
145
  const ret = wasm.wasmpage_height_at(this.__wbg_ptr, target_dpi);
146
146
  return ret >>> 0;
147
147
  }
148
- /**
149
- * Render the page at `target_dpi` and return raw RGBA pixels
150
- * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
151
- *
152
- * Throws on decode error.
153
- * @param {number} target_dpi
154
- * @returns {Uint8ClampedArray}
155
- */
156
- render(target_dpi) {
157
- const ret = wasm.wasmpage_render(this.__wbg_ptr, target_dpi);
158
- if (ret[2]) {
159
- throw takeFromExternrefTable0(ret[1]);
160
- }
161
- return takeFromExternrefTable0(ret[0]);
162
- }
163
148
  /**
164
149
  * Fast coarse render — decodes only the first BG44 chunk (~5 ms for a
165
150
  * typical color page).
@@ -180,6 +165,21 @@ export class WasmPage {
180
165
  }
181
166
  return takeFromExternrefTable0(ret[0]);
182
167
  }
168
+ /**
169
+ * Render the page at `target_dpi` and return raw RGBA pixels
170
+ * (`Uint8ClampedArray`, suitable for `new ImageData(pixels, w, h)`).
171
+ *
172
+ * Throws on decode error.
173
+ * @param {number} target_dpi
174
+ * @returns {Uint8ClampedArray}
175
+ */
176
+ render(target_dpi) {
177
+ const ret = wasm.wasmpage_render(this.__wbg_ptr, target_dpi);
178
+ if (ret[2]) {
179
+ throw takeFromExternrefTable0(ret[1]);
180
+ }
181
+ return takeFromExternrefTable0(ret[0]);
182
+ }
183
183
  /**
184
184
  * Render into a caller-owned [`WasmPixmap`], reusing its Rust-side
185
185
  * allocation (#611). No JS-side allocation, no wasm→JS copy — consume
@@ -479,29 +479,29 @@ if (Symbol.dispose) WasmPixmap.prototype[Symbol.dispose] = WasmPixmap.prototype.
479
479
  function __wbg_get_imports() {
480
480
  const import0 = {
481
481
  __proto__: null,
482
- __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
482
+ __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
483
483
  const ret = Error(getStringFromWasm0(arg0, arg1));
484
484
  return ret;
485
485
  },
486
- __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
486
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
487
487
  throw new Error(getStringFromWasm0(arg0, arg1));
488
488
  },
489
- __wbg_length_13032799523c5735: function(arg0) {
489
+ __wbg_length_ff98c95d19109ba4: function(arg0) {
490
490
  const ret = arg0.length;
491
491
  return ret;
492
492
  },
493
- __wbg_new_with_length_5d351ffdb6e3397d: function(arg0) {
493
+ __wbg_new_with_length_ac9c609232fb2d1d: function(arg0) {
494
494
  const ret = new Uint8ClampedArray(arg0 >>> 0);
495
495
  return ret;
496
496
  },
497
- __wbg_set_5c15d3c5973de97a: function(arg0, arg1, arg2) {
497
+ __wbg_set_0488601468e80715: function(arg0, arg1, arg2) {
498
498
  arg0.set(getArrayU8FromWasm0(arg1, arg2));
499
499
  },
500
500
  __wbg_wasmpixmap_new: function(arg0) {
501
501
  const ret = WasmPixmap.__wrap(arg0);
502
502
  return ret;
503
503
  },
504
- __wbindgen_cast_0000000000000001: function(arg0, arg1) {
504
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
505
505
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8ClampedArray")`.
506
506
  const ret = getArrayU8FromWasm0(arg0, arg1);
507
507
  return ret;
Binary file