roxify 1.4.0 → 1.4.1
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/dist/cli.js +3 -2
- package/dist/roxify-cli +0 -0
- package/dist/utils/constants.d.ts +17 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/decoder.js +50 -1
- package/dist/utils/rust-cli-wrapper.d.ts +1 -1
- package/dist/utils/rust-cli-wrapper.js +4 -1
- package/dist/utils/types.d.ts +1 -0
- package/libroxify_native.node +0 -0
- package/package.json +1 -1
- package/README.md +0 -391
package/dist/cli.js
CHANGED
|
@@ -211,7 +211,8 @@ async function encodeCommand(args) {
|
|
|
211
211
|
});
|
|
212
212
|
}, 500);
|
|
213
213
|
const encryptType = parsed.encrypt === 'xor' ? 'xor' : 'aes';
|
|
214
|
-
|
|
214
|
+
const fileName = basename(inputPaths[0]);
|
|
215
|
+
await encodeWithRustCLI(inputPaths.length === 1 ? resolvedInputs[0] : resolvedInputs[0], resolvedOutput, 12, parsed.passphrase, encryptType, fileName);
|
|
215
216
|
clearInterval(progressInterval);
|
|
216
217
|
const encodeTime = Date.now() - startTime;
|
|
217
218
|
encodeBar.update(100, {
|
|
@@ -284,7 +285,7 @@ async function encodeCommand(args) {
|
|
|
284
285
|
mode,
|
|
285
286
|
name: parsed.outputName || 'archive',
|
|
286
287
|
skipOptimization: false,
|
|
287
|
-
compressionLevel:
|
|
288
|
+
compressionLevel: 12,
|
|
288
289
|
outputFormat: 'auto',
|
|
289
290
|
});
|
|
290
291
|
if (parsed.verbose)
|
package/dist/roxify-cli
CHANGED
|
Binary file
|
|
@@ -37,3 +37,20 @@ export declare const COMPRESSION_MARKERS: {
|
|
|
37
37
|
b: number;
|
|
38
38
|
}[];
|
|
39
39
|
};
|
|
40
|
+
export declare const FORMAT_MARKERS: {
|
|
41
|
+
png: {
|
|
42
|
+
r: number;
|
|
43
|
+
g: number;
|
|
44
|
+
b: number;
|
|
45
|
+
};
|
|
46
|
+
webp: {
|
|
47
|
+
r: number;
|
|
48
|
+
g: number;
|
|
49
|
+
b: number;
|
|
50
|
+
};
|
|
51
|
+
jxl: {
|
|
52
|
+
r: number;
|
|
53
|
+
g: number;
|
|
54
|
+
b: number;
|
|
55
|
+
};
|
|
56
|
+
};
|
package/dist/utils/constants.js
CHANGED
package/dist/utils/decoder.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { execFileSync } from 'child_process';
|
|
1
2
|
import cliProgress from 'cli-progress';
|
|
2
|
-
import { readFileSync } from 'fs';
|
|
3
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
4
|
+
import { tmpdir } from 'os';
|
|
5
|
+
import { join } from 'path';
|
|
3
6
|
import extract from 'png-chunks-extract';
|
|
4
7
|
import sharp from 'sharp';
|
|
5
8
|
import { unpackBuffer } from '../pack.js';
|
|
@@ -34,6 +37,52 @@ async function tryDecompress(payload, onProgress) {
|
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
}
|
|
40
|
+
function detectImageFormat(buf) {
|
|
41
|
+
if (buf.length < 12)
|
|
42
|
+
return 'unknown';
|
|
43
|
+
if (buf[0] === 0x89 &&
|
|
44
|
+
buf[1] === 0x50 &&
|
|
45
|
+
buf[2] === 0x4e &&
|
|
46
|
+
buf[3] === 0x47) {
|
|
47
|
+
return 'png';
|
|
48
|
+
}
|
|
49
|
+
if (buf[0] === 0x52 &&
|
|
50
|
+
buf[1] === 0x49 &&
|
|
51
|
+
buf[2] === 0x46 &&
|
|
52
|
+
buf[3] === 0x46 &&
|
|
53
|
+
buf[8] === 0x57 &&
|
|
54
|
+
buf[9] === 0x45 &&
|
|
55
|
+
buf[10] === 0x42 &&
|
|
56
|
+
buf[11] === 0x50) {
|
|
57
|
+
return 'webp';
|
|
58
|
+
}
|
|
59
|
+
if (buf[0] === 0xff && buf[1] === 0x0a) {
|
|
60
|
+
return 'jxl';
|
|
61
|
+
}
|
|
62
|
+
return 'unknown';
|
|
63
|
+
}
|
|
64
|
+
function convertToPng(buf, format) {
|
|
65
|
+
const tempDir = mkdtempSync(join(tmpdir(), 'rox-decode-'));
|
|
66
|
+
const inputPath = join(tempDir, format === 'webp' ? 'input.webp' : 'input.jxl');
|
|
67
|
+
const outputPath = join(tempDir, 'output.png');
|
|
68
|
+
try {
|
|
69
|
+
writeFileSync(inputPath, buf);
|
|
70
|
+
if (format === 'webp') {
|
|
71
|
+
execFileSync('dwebp', [inputPath, '-o', outputPath]);
|
|
72
|
+
}
|
|
73
|
+
else if (format === 'jxl') {
|
|
74
|
+
execFileSync('djxl', [inputPath, outputPath]);
|
|
75
|
+
}
|
|
76
|
+
const pngBuf = readFileSync(outputPath);
|
|
77
|
+
return pngBuf;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
try {
|
|
81
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
82
|
+
}
|
|
83
|
+
catch (e) { }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
37
86
|
export async function decodePngToBinary(input, opts = {}) {
|
|
38
87
|
let pngBuf;
|
|
39
88
|
if (Buffer.isBuffer(input)) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function isRustBinaryAvailable(): boolean;
|
|
2
|
-
export declare function encodeWithRustCLI(inputPath: string, outputPath: string, compressionLevel?: number, passphrase?: string, encryptType?: 'aes' | 'xor'): Promise<void>;
|
|
2
|
+
export declare function encodeWithRustCLI(inputPath: string, outputPath: string, compressionLevel?: number, passphrase?: string, encryptType?: 'aes' | 'xor', name?: string): Promise<void>;
|
|
@@ -56,7 +56,7 @@ function findRustBinary() {
|
|
|
56
56
|
export function isRustBinaryAvailable() {
|
|
57
57
|
return findRustBinary() !== null;
|
|
58
58
|
}
|
|
59
|
-
export async function encodeWithRustCLI(inputPath, outputPath, compressionLevel = 3, passphrase, encryptType = 'aes') {
|
|
59
|
+
export async function encodeWithRustCLI(inputPath, outputPath, compressionLevel = 3, passphrase, encryptType = 'aes', name) {
|
|
60
60
|
const cliPath = findRustBinary();
|
|
61
61
|
if (!cliPath) {
|
|
62
62
|
throw new Error('Rust CLI binary not found. Run: cargo build --release');
|
|
@@ -69,6 +69,9 @@ export async function encodeWithRustCLI(inputPath, outputPath, compressionLevel
|
|
|
69
69
|
'--level',
|
|
70
70
|
String(compressionLevel),
|
|
71
71
|
];
|
|
72
|
+
if (name) {
|
|
73
|
+
args.push('--name', name);
|
|
74
|
+
}
|
|
72
75
|
if (passphrase) {
|
|
73
76
|
args.push('--passphrase', passphrase);
|
|
74
77
|
args.push('--encrypt', encryptType);
|
package/dist/utils/types.d.ts
CHANGED
package/libroxify_native.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
# RoxCompressor Transform
|
|
2
|
-
|
|
3
|
-
> Encode binary data into PNG images and decode them back. Fast, efficient, with optional encryption and native Rust acceleration.
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/roxify)
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
|
|
8
|
-
## Features
|
|
9
|
-
|
|
10
|
-
- ⚡ **Blazing Fast**: Native Rust acceleration via N-API — **1GB/s** throughput on modern hardware
|
|
11
|
-
- 🚀 **Optimized Compression**: Multi-threaded Zstd compression (level 19) with parallel processing
|
|
12
|
-
- 🔒 **Secure**: AES-256-GCM encryption support with PBKDF2 key derivation
|
|
13
|
-
- 🎨 **Multiple modes**: Compact, chunk, pixel, and screenshot modes
|
|
14
|
-
- 📦 **CLI & API**: Use as command-line tool or JavaScript library
|
|
15
|
-
- 🔄 **Lossless**: Perfect roundtrip encoding/decoding
|
|
16
|
-
- 📖 **Full TSDoc**: Complete TypeScript documentation
|
|
17
|
-
- 🦀 **Rust Powered**: Optional native module for extreme performance (falls back to pure JS)
|
|
18
|
-
|
|
19
|
-
## Real-world benchmarks 🔧
|
|
20
|
-
|
|
21
|
-
**Highlights**
|
|
22
|
-
|
|
23
|
-
- Practical benchmarks on large codebase datasets showing significant compression and high throughput while handling many small files efficiently.
|
|
24
|
-
|
|
25
|
-
**Results**
|
|
26
|
-
|
|
27
|
-
| Dataset | Files | Original | Compressed | Ratio | Time | Throughput | Notes |
|
|
28
|
-
| -------- | ------: | -------: | ---------: | --------: | -----: | ---------: | ------------------------------------------- |
|
|
29
|
-
| 4,000 MB | 731,340 | 3.93 GB | 111.42 MB | **2.8%** | 26.9 s | 149.4 MB/s | gzip: 2.26 GB (57.5%); 7z: 1.87 GB (47.6%) |
|
|
30
|
-
| 1,000 MB | 141,522 | 1.03 GB | 205 MB | **19.4%** | ~6.2 s | ≈170 MB/s | shows benefits for many-small-file datasets |
|
|
31
|
-
|
|
32
|
-
### Methodology
|
|
33
|
-
|
|
34
|
-
- Compression: multithreaded Zstd (level 19) and Brotli (configurable).
|
|
35
|
-
- Setup: parallel I/O and multithreaded compression on modern SSD-backed systems.
|
|
36
|
-
- Measurements: wall-clock time; throughput = original size / time; comparisons against gzip and 7z with typical defaults.
|
|
37
|
-
- Reproducibility: full benchmark details, commands and raw data are available in `docs/BENCHMARK_FINAL_REPORT.md`.
|
|
38
|
-
|
|
39
|
-
These results demonstrate Roxify's strength for packaging large codebases and many-small-file archives where speed and a good compression/throughput trade-off matter.
|
|
40
|
-
|
|
41
|
-
## Documentation
|
|
42
|
-
|
|
43
|
-
- 📘 **[CLI Documentation](./CLI.md)** - Complete command-line usage guide
|
|
44
|
-
- 📗 **[JavaScript SDK](./JAVASCRIPT_SDK.md)** - Programmatic API reference with examples
|
|
45
|
-
- 📙 **[Quick Start](#quick-start)** - Get started in 2 minutes
|
|
46
|
-
|
|
47
|
-
## Installation
|
|
48
|
-
|
|
49
|
-
### As CLI tool (npx)
|
|
50
|
-
|
|
51
|
-
No installation needed! Use directly with npx:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npx rox encode input.zip output.png
|
|
55
|
-
npx rox decode output.png original.zip
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### As library
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
npm install roxify
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## CLI Usage
|
|
65
|
-
|
|
66
|
-
### Quick Start
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# Encode a file
|
|
70
|
-
npx rox encode document.pdf document.png
|
|
71
|
-
|
|
72
|
-
# Decode it back
|
|
73
|
-
npx rox decode document.png document.pdf
|
|
74
|
-
|
|
75
|
-
# With encryption
|
|
76
|
-
npx rox encode secret.zip secret.png -p mypassword
|
|
77
|
-
npx rox decode secret.png secret.zip -p mypassword
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### CLI Commands
|
|
81
|
-
|
|
82
|
-
#### `encode` - Encode file to PNG
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npx rox encode <input> [output] [options]
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Options:**
|
|
89
|
-
|
|
90
|
-
- `-p, --passphrase <pass>` - Encrypt with passphrase (AES-256-GCM)
|
|
91
|
-
- `-m, --mode <mode>` - Encoding mode: `compact|chunk|pixel|screenshot` (default: `screenshot`)
|
|
92
|
-
- `-q, --quality <0-11>` - Brotli compression quality (default: `1`)
|
|
93
|
-
- `0` = fastest, largest
|
|
94
|
-
- `11` = slowest, smallest
|
|
95
|
-
- `-e, --encrypt <type>` - Encryption: `auto|aes|xor|none` (default: `aes` if passphrase)
|
|
96
|
-
- `--no-compress` - Disable compression
|
|
97
|
-
- `-o, --output <path>` - Output file path
|
|
98
|
-
|
|
99
|
-
**Examples:**
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
# Basic encoding
|
|
103
|
-
npx rox encode data.bin output.png
|
|
104
|
-
|
|
105
|
-
# Fast compression for large files
|
|
106
|
-
npx rox encode large-video.mp4 output.png -q 0
|
|
107
|
-
|
|
108
|
-
# High compression for small files
|
|
109
|
-
npx rox encode config.json output.png -q 11
|
|
110
|
-
|
|
111
|
-
# With encryption
|
|
112
|
-
npx rox encode secret.pdf secure.png -p "my secure password"
|
|
113
|
-
|
|
114
|
-
# Compact mode (smallest PNG)
|
|
115
|
-
npx rox encode data.bin tiny.png -m compact
|
|
116
|
-
|
|
117
|
-
# Screenshot mode (recommended, looks like a real image)
|
|
118
|
-
npx rox encode archive.tar.gz screenshot.png -m screenshot
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
#### `decode` - Decode PNG to file
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
npx rox decode <input> [output] [options]
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Options:**
|
|
128
|
-
|
|
129
|
-
- `-p, --passphrase <pass>` - Decryption passphrase
|
|
130
|
-
- `-o, --output <path>` - Output file path (auto-detected from metadata if not provided)
|
|
131
|
-
|
|
132
|
-
**Examples:**
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
# Basic decoding
|
|
136
|
-
npx rox decode encoded.png output.bin
|
|
137
|
-
|
|
138
|
-
# Auto-detect filename from metadata
|
|
139
|
-
npx rox decode encoded.png
|
|
140
|
-
|
|
141
|
-
# With decryption
|
|
142
|
-
npx rox decode encrypted.png output.pdf -p "my secure password"
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## JavaScript API
|
|
146
|
-
|
|
147
|
-
### Basic Usage
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
import { encodeBinaryToPng, decodePngToBinary } from 'roxify';
|
|
151
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
152
|
-
|
|
153
|
-
// Encode
|
|
154
|
-
const input = readFileSync('input.zip');
|
|
155
|
-
const png = await encodeBinaryToPng(input, {
|
|
156
|
-
mode: 'screenshot',
|
|
157
|
-
name: 'input.zip',
|
|
158
|
-
});
|
|
159
|
-
writeFileSync('output.png', png);
|
|
160
|
-
|
|
161
|
-
// Decode
|
|
162
|
-
const encoded = readFileSync('output.png');
|
|
163
|
-
const result = await decodePngToBinary(encoded);
|
|
164
|
-
writeFileSync(result.meta?.name || 'output.bin', result.buf);
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### With Encryption
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
// Encode with AES-256-GCM
|
|
171
|
-
const png = await encodeBinaryToPng(input, {
|
|
172
|
-
mode: 'screenshot',
|
|
173
|
-
passphrase: 'my-secret-password',
|
|
174
|
-
encrypt: 'aes',
|
|
175
|
-
name: 'secret.zip',
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
// Decode with passphrase
|
|
179
|
-
const result = await decodePngToBinary(encoded, {
|
|
180
|
-
passphrase: 'my-secret-password',
|
|
181
|
-
});
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Fast Compression
|
|
185
|
-
|
|
186
|
-
```typescript
|
|
187
|
-
// Optimize for speed (recommended for large files)
|
|
188
|
-
const png = await encodeBinaryToPng(largeBuffer, {
|
|
189
|
-
mode: 'screenshot',
|
|
190
|
-
brQuality: 0, // Fastest
|
|
191
|
-
name: 'large-file.bin',
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// Optimize for size (recommended for small files)
|
|
195
|
-
const png = await encodeBinaryToPng(smallBuffer, {
|
|
196
|
-
mode: 'compact',
|
|
197
|
-
brQuality: 11, // Best compression
|
|
198
|
-
name: 'config.json',
|
|
199
|
-
});
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Encoding Modes
|
|
203
|
-
|
|
204
|
-
#### `screenshot` (Recommended)
|
|
205
|
-
|
|
206
|
-
Encodes data as RGB pixel values, optimized for screenshot-like appearance. Best balance of size and compatibility.
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
const png = await encodeBinaryToPng(data, { mode: 'screenshot' });
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
#### `compact` (Smallest)
|
|
213
|
-
|
|
214
|
-
Minimal 1x1 PNG with data in custom chunk. Fastest and smallest.
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
const png = await encodeBinaryToPng(data, { mode: 'compact' });
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
#### `pixel`
|
|
221
|
-
|
|
222
|
-
Encodes data as RGB pixel values without screenshot optimization.
|
|
223
|
-
|
|
224
|
-
```typescript
|
|
225
|
-
const png = await encodeBinaryToPng(data, { mode: 'pixel' });
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
#### `chunk`
|
|
229
|
-
|
|
230
|
-
Standard PNG with data in custom rXDT chunk.
|
|
231
|
-
|
|
232
|
-
```typescript
|
|
233
|
-
const png = await encodeBinaryToPng(data, { mode: 'chunk' });
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
## API Reference
|
|
237
|
-
|
|
238
|
-
### `encodeBinaryToPng(input, options)`
|
|
239
|
-
|
|
240
|
-
Encodes binary data into a PNG image.
|
|
241
|
-
|
|
242
|
-
**Parameters:**
|
|
243
|
-
|
|
244
|
-
- `input: Buffer` - The binary data to encode
|
|
245
|
-
- `options?: EncodeOptions` - Encoding options
|
|
246
|
-
|
|
247
|
-
**Returns:** `Promise<Buffer>` - The encoded PNG
|
|
248
|
-
|
|
249
|
-
**Options:**
|
|
250
|
-
|
|
251
|
-
```typescript
|
|
252
|
-
interface EncodeOptions {
|
|
253
|
-
// Compression algorithm ('br' = Brotli, 'none' = no compression)
|
|
254
|
-
compression?: 'br' | 'none';
|
|
255
|
-
|
|
256
|
-
// Passphrase for encryption
|
|
257
|
-
passphrase?: string;
|
|
258
|
-
|
|
259
|
-
// Original filename to embed
|
|
260
|
-
name?: string;
|
|
261
|
-
|
|
262
|
-
// Encoding mode
|
|
263
|
-
mode?: 'compact' | 'chunk' | 'pixel' | 'screenshot';
|
|
264
|
-
|
|
265
|
-
// Encryption method
|
|
266
|
-
encrypt?: 'auto' | 'aes' | 'xor' | 'none';
|
|
267
|
-
|
|
268
|
-
// Output format
|
|
269
|
-
output?: 'auto' | 'png' | 'rox';
|
|
270
|
-
|
|
271
|
-
// Include filename in metadata (default: true)
|
|
272
|
-
includeName?: boolean;
|
|
273
|
-
|
|
274
|
-
// Brotli quality 0-11 (default: 1)
|
|
275
|
-
brQuality?: number;
|
|
276
|
-
}
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### `decodePngToBinary(pngBuf, options)`
|
|
280
|
-
|
|
281
|
-
Decodes a PNG image back to binary data.
|
|
282
|
-
|
|
283
|
-
**Parameters:**
|
|
284
|
-
|
|
285
|
-
- `pngBuf: Buffer` - The PNG image to decode
|
|
286
|
-
- `options?: DecodeOptions` - Decoding options
|
|
287
|
-
|
|
288
|
-
**Returns:** `Promise<DecodeResult>` - The decoded data and metadata
|
|
289
|
-
|
|
290
|
-
**Options:**
|
|
291
|
-
|
|
292
|
-
```typescript
|
|
293
|
-
interface DecodeOptions {
|
|
294
|
-
// Passphrase for decryption
|
|
295
|
-
passphrase?: string;
|
|
296
|
-
}
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
**Result:**
|
|
300
|
-
|
|
301
|
-
```typescript
|
|
302
|
-
interface DecodeResult {
|
|
303
|
-
// Decoded binary data
|
|
304
|
-
buf: Buffer;
|
|
305
|
-
|
|
306
|
-
// Extracted metadata
|
|
307
|
-
meta?: {
|
|
308
|
-
// Original filename
|
|
309
|
-
name?: string;
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
## Performance Tips
|
|
315
|
-
|
|
316
|
-
### For Large Files (>10 MB)
|
|
317
|
-
|
|
318
|
-
```bash
|
|
319
|
-
# Use quality 0 for fastest encoding
|
|
320
|
-
npx rox encode large.bin output.png -q 0
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
```typescript
|
|
324
|
-
const png = await encodeBinaryToPng(largeFile, {
|
|
325
|
-
mode: 'screenshot',
|
|
326
|
-
brQuality: 0, // 10-20x faster than default
|
|
327
|
-
});
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
### For Small Files (<1 MB)
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
# Use quality 11 for best compression
|
|
334
|
-
npx rox encode small.json output.png -q 11 -m compact
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
```typescript
|
|
338
|
-
const png = await encodeBinaryToPng(smallFile, {
|
|
339
|
-
mode: 'compact',
|
|
340
|
-
brQuality: 11, // Best compression ratio
|
|
341
|
-
});
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### Benchmark Results
|
|
345
|
-
|
|
346
|
-
File: 3.8 MB binary
|
|
347
|
-
|
|
348
|
-
- **Quality 0**: ~500-800ms, output ~1.2 MB
|
|
349
|
-
- **Quality 1** (default): ~1-2s, output ~800 KB
|
|
350
|
-
- **Quality 5**: ~8-12s, output ~750 KB
|
|
351
|
-
- **Quality 11**: ~20-30s, output ~720 KB
|
|
352
|
-
|
|
353
|
-
## Error Handling
|
|
354
|
-
|
|
355
|
-
```typescript
|
|
356
|
-
try {
|
|
357
|
-
const result = await decodePngToBinary(encoded, {
|
|
358
|
-
passphrase: 'wrong-password',
|
|
359
|
-
});
|
|
360
|
-
} catch (err) {
|
|
361
|
-
if (err.message.includes('Incorrect passphrase')) {
|
|
362
|
-
console.error('Wrong password!');
|
|
363
|
-
} else if (err.message.includes('Invalid ROX format')) {
|
|
364
|
-
console.error('Not a valid RoxCompressor PNG');
|
|
365
|
-
} else {
|
|
366
|
-
console.error('Decode failed:', err.message);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
## Security
|
|
372
|
-
|
|
373
|
-
- **AES-256-GCM**: Authenticated encryption with 100,000 PBKDF2 iterations
|
|
374
|
-
- **XOR cipher**: Simple obfuscation (not cryptographically secure)
|
|
375
|
-
- **No encryption**: Data is compressed but not encrypted
|
|
376
|
-
|
|
377
|
-
⚠️ **Warning**: Use strong passphrases for sensitive data. The `xor` encryption mode is not secure and should only be used for obfuscation.
|
|
378
|
-
|
|
379
|
-
## License
|
|
380
|
-
|
|
381
|
-
MIT © RoxCompressor
|
|
382
|
-
|
|
383
|
-
## Contributing
|
|
384
|
-
|
|
385
|
-
Contributions welcome! Please open an issue or PR on GitHub.
|
|
386
|
-
|
|
387
|
-
## Links
|
|
388
|
-
|
|
389
|
-
- [GitHub Repository](https://github.com/RoxasYTB/RoxCompressor)
|
|
390
|
-
- [npm Package](https://www.npmjs.com/package/roxify)
|
|
391
|
-
- [Report Issues](https://github.com/RoxasYTB/RoxCompressor/issues)
|