roxify 1.9.2 → 1.9.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/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "roxify_native"
3
- version = "1.9.2"
3
+ version = "1.9.3"
4
4
  edition = "2021"
5
5
  publish = false
6
6
 
Binary file
@@ -138,12 +138,22 @@ pub fn get_png_metadata(png_data: &[u8]) -> Result<(u32, u32, u8, u8), String> {
138
138
 
139
139
  pub fn extract_payload_from_png(png_data: &[u8]) -> Result<Vec<u8>, String> {
140
140
  if let Ok(payload) = extract_payload_direct(png_data) {
141
- return Ok(payload);
141
+ if validate_payload_deep(&payload) {
142
+ return Ok(payload);
143
+ }
142
144
  }
143
145
  let reconst = crate::reconstitution::crop_and_reconstitute(png_data)?;
144
146
  extract_payload_direct(&reconst)
145
147
  }
146
148
 
149
+ fn validate_payload_deep(payload: &[u8]) -> bool {
150
+ if payload.len() < 5 { return false; }
151
+ if payload[0] == 0x01 || payload[0] == 0x02 { return true; }
152
+ let compressed = if payload[0] == 0x00 { &payload[1..] } else { payload };
153
+ if compressed.starts_with(b"ROX1") { return true; }
154
+ crate::core::zstd_decompress_bytes(compressed, None).is_ok()
155
+ }
156
+
147
157
  fn find_pixel_header(raw: &[u8]) -> Result<usize, String> {
148
158
  let magic = b"PXL1";
149
159
  for i in 0..(raw.len().saturating_sub(magic.len())) {
@@ -373,9 +373,31 @@ pub fn crop_and_reconstitute(png_data: &[u8]) -> Result<Vec<u8>, String> {
373
373
  let mut out = RgbaImage::from_pixel(best_logical_w, best_logical_h, Rgba([0, 0, 0, 255]));
374
374
  for ly in 0..best_logical_h {
375
375
  for lx in 0..best_logical_w {
376
- let px = (sx as f64 + (lx as f64 + 0.5) * scale_x) as u32;
377
- let py = (sy as f64 + (ly as f64 + 0.5) * scale_y) as u32;
378
- out.put_pixel(lx, ly, Rgba(get_pixel(min(px, width - 1), min(py, height - 1))));
376
+ let bx0 = (sx as f64 + lx as f64 * scale_x).round() as u32;
377
+ let bx1 = (sx as f64 + (lx + 1) as f64 * scale_x).round() as u32;
378
+ let by0 = (sy as f64 + ly as f64 * scale_y).round() as u32;
379
+ let by1 = (sy as f64 + (ly + 1) as f64 * scale_y).round() as u32;
380
+ let bx0 = min(bx0, width - 1);
381
+ let bx1 = min(bx1, width).max(bx0 + 1);
382
+ let by0 = min(by0, height - 1);
383
+ let by1 = min(by1, height).max(by0 + 1);
384
+
385
+ let mut rs: Vec<u8> = Vec::new();
386
+ let mut gs: Vec<u8> = Vec::new();
387
+ let mut bs: Vec<u8> = Vec::new();
388
+ for py in by0..by1 {
389
+ for px in bx0..bx1 {
390
+ let p = get_pixel(px, py);
391
+ rs.push(p[0]);
392
+ gs.push(p[1]);
393
+ bs.push(p[2]);
394
+ }
395
+ }
396
+ rs.sort_unstable();
397
+ gs.sort_unstable();
398
+ bs.sort_unstable();
399
+ let mid = rs.len() / 2;
400
+ out.put_pixel(lx, ly, Rgba([rs[mid], gs[mid], bs[mid], 255]));
379
401
  }
380
402
  }
381
403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
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",
@@ -106,7 +106,7 @@ function ensureCliBinary() {
106
106
  if (existing && existing !== dest) {
107
107
  copyFileSync(existing, dest);
108
108
  if (platform() !== 'win32') {
109
- try { require('fs').chmodSync(dest, 0o755); } catch {}
109
+ try { require('fs').chmodSync(dest, 0o755); } catch { }
110
110
  }
111
111
  console.log(`roxify: Copied CLI binary from ${existing}`);
112
112
  return;
@@ -119,7 +119,7 @@ function ensureCliBinary() {
119
119
  if (existsSync(built)) {
120
120
  copyFileSync(built, dest);
121
121
  if (platform() !== 'win32') {
122
- try { require('fs').chmodSync(dest, 0o755); } catch {}
122
+ try { require('fs').chmodSync(dest, 0o755); } catch { }
123
123
  }
124
124
  console.log('roxify: CLI binary built and copied to dist/');
125
125
  }