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
package/dist/roxify_native.exe
CHANGED
|
Binary file
|
package/native/png_utils.rs
CHANGED
|
@@ -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
|
-
|
|
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())) {
|
package/native/reconstitution.rs
CHANGED
|
@@ -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
|
|
377
|
-
let
|
|
378
|
-
|
|
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
|
Binary file
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -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
|
}
|