roxify 1.12.9 → 1.12.11

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/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "roxify_native"
3
- version = "1.12.9"
3
+ version = "1.12.11"
4
4
  edition = "2021"
5
5
  publish = false
6
6
 
Binary file
@@ -481,10 +481,9 @@ export async function encodeBinaryToPng(input, opts = {}) {
481
481
  }
482
482
  const totalDataBytes = logicalWidth * logicalHeight * 3;
483
483
  const fullData = Buffer.alloc(totalDataBytes);
484
- const markerStartPos = (logicalHeight - 1) * logicalWidth * 3 +
485
- (logicalWidth - MARKER_END.length) * 3;
486
- flatData.copy(fullData, 0, 0, Math.min(flatData.length, markerStartPos));
487
- markerEndBytes.copy(fullData, markerStartPos);
484
+ const markerEndPos = totalDataBytes - MARKER_END.length * 3;
485
+ flatData.copy(fullData, 0, 0, Math.min(flatData.length, markerEndPos));
486
+ markerEndBytes.copy(fullData, markerEndPos);
488
487
  for (let row = 0; row < height; row++) {
489
488
  raw[row * stride] = 0;
490
489
  fullData.copy(raw, row * stride + 1, row * width * 3, (row + 1) * width * 3);
@@ -494,6 +493,14 @@ export async function encodeBinaryToPng(input, opts = {}) {
494
493
  raw = Buffer.alloc(width * height * 3);
495
494
  const flatData = Buffer.concat(dataWithMarkers);
496
495
  flatData.copy(raw, 0, 0, Math.min(flatData.length, raw.length));
496
+ const markerEndBytes = Buffer.alloc(MARKER_END.length * 3);
497
+ for (let i = 0; i < MARKER_END.length; i++) {
498
+ markerEndBytes[i * 3] = MARKER_END[i].r;
499
+ markerEndBytes[i * 3 + 1] = MARKER_END[i].g;
500
+ markerEndBytes[i * 3 + 2] = MARKER_END[i].b;
501
+ }
502
+ const markerEndPos = raw.length - MARKER_END.length * 3;
503
+ markerEndBytes.copy(raw, markerEndPos);
497
504
  }
498
505
  if (opts.onProgress)
499
506
  opts.onProgress({ phase: 'png_gen', loaded: 0, total: height });
@@ -445,7 +445,12 @@ fn write_idat_streaming<W: Write, R: Read>(
445
445
  deflate_block_remaining -= take;
446
446
  cols_written += take;
447
447
  } else {
448
- let take = need.min(zero_remaining).min(buf_size);
448
+ let max_before_marker = if flat_pos < marker_end_pos {
449
+ marker_end_pos - flat_pos
450
+ } else {
451
+ need
452
+ };
453
+ let take = need.min(zero_remaining).min(buf_size).min(max_before_marker);
449
454
  if take == 0 { break; }
450
455
  let zeros = vec![0u8; take];
451
456
  w.write_all(&zeros)?;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.12.9",
3
+ "version": "1.12.11",
4
4
  "type": "module",
5
5
  "description": "Ultra-lightweight PNG steganography with native Rust acceleration. Encode binary data into PNG images with zstd compression.",
6
6
  "main": "dist/index.js",
@@ -107,5 +107,8 @@
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=18.0.0"
110
+ },
111
+ "dependencies": {
112
+ "pngjs": "^7.0.0"
110
113
  }
111
- }
114
+ }