@pixzle/cli 0.0.20 → 0.0.21
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 +16 -4
- package/dist/package.json +4 -3
- package/dist/src/commands/restore.js +37 -5
- package/dist/src/commands/restore.js.map +1 -1
- package/dist/src/types.d.ts +5 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ pixzle shuffle <images...> -o <output_directory> [options]
|
|
|
47
47
|
|--------|-------------|----------|---------|
|
|
48
48
|
| `-o, --output <dir>` | Output directory for fragments and manifest | ✅ | - |
|
|
49
49
|
| `-b, --block-size <size>` | Pixel block size (positive integer) | ❌ | 10 |
|
|
50
|
-
| `-p, --prefix <prefix>` | Prefix for fragment files | ❌ | "
|
|
50
|
+
| `-p, --prefix <prefix>` | Prefix for fragment files | ❌ | "img" |
|
|
51
51
|
| `-s, --seed <seed>` | Random seed (integer) | ❌ | auto-generated |
|
|
52
52
|
| `--preserve-name` | Preserve original file names | ❌ | false |
|
|
53
53
|
| `--cross-image-shuffle` | Shuffle blocks across all images instead of within each image independently | ❌ | false (per-image shuffle by default) |
|
|
@@ -87,7 +87,7 @@ output/
|
|
|
87
87
|
|
|
88
88
|
### Restore Command
|
|
89
89
|
|
|
90
|
-
Restore fragmented images using the manifest file.
|
|
90
|
+
Restore fragmented images using the manifest file or manual configuration.
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
93
|
pixzle restore <fragments...> -m <manifest_path> -o <output_directory> [options]
|
|
@@ -97,16 +97,28 @@ pixzle restore <fragments...> -m <manifest_path> -o <output_directory> [options]
|
|
|
97
97
|
|
|
98
98
|
| Option | Description | Required |
|
|
99
99
|
|--------|-------------|----------|
|
|
100
|
-
| `-m, --manifest <path>` | Path to the manifest.json file |
|
|
100
|
+
| `-m, --manifest <path>` | Path to the manifest.json file | ⚠️ |
|
|
101
101
|
| `-o, --output <dir>` | Output directory for restored images | ✅ |
|
|
102
|
+
| `-b, --block-size <number>` | Pixel block size (positive integer) | ❌ (required if manifest missing) |
|
|
103
|
+
| `-s, --seed <number>` | Random seed (integer) | ❌ (required if manifest missing) |
|
|
104
|
+
| `-w, --width <number>` | Image width | ❌ (required if manifest missing) |
|
|
105
|
+
| `-h, --height <number>` | Image height | ❌ (required if manifest missing) |
|
|
106
|
+
|
|
107
|
+
> [!NOTE]
|
|
108
|
+
> When using manual options (`-b`, `-s`, `-w`, `-h`), only a single image can be restored.
|
|
102
109
|
|
|
103
110
|
#### Examples
|
|
104
111
|
|
|
105
|
-
**Basic restoration:**
|
|
112
|
+
**Basic restoration (using manifest):**
|
|
106
113
|
```bash
|
|
107
114
|
pixzle restore ./fragments/*.png -m ./fragments/manifest.json -o ./restored
|
|
108
115
|
```
|
|
109
116
|
|
|
117
|
+
**Manual restoration (without manifest):**
|
|
118
|
+
```bash
|
|
119
|
+
pixzle restore ./fragment.png -o ./restored -b 10 -s 12345 -w 500 -h 500
|
|
120
|
+
```
|
|
121
|
+
|
|
110
122
|
**Specific fragments:**
|
|
111
123
|
```bash
|
|
112
124
|
pixzle restore fragment_0000.png fragment_0001.png fragment_0002.png -m manifest.json -o ./output
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixzle/cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "CLI implementation of image fragmentation and restoration
|
|
3
|
+
"version": "0.0.20",
|
|
4
|
+
"description": "CLI implementation of image fragmentation and restoration",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc -p tsconfig.build.json",
|
|
16
16
|
"build:check": "tsc -p tsconfig.build.json --noEmit",
|
|
17
|
-
"test": "vitest",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest",
|
|
18
19
|
"dev": "tsx src/cli.ts"
|
|
19
20
|
},
|
|
20
21
|
"keywords": [],
|
|
@@ -15,8 +15,12 @@ function registerRestoreCommand(program) {
|
|
|
15
15
|
.command("restore")
|
|
16
16
|
.description("Restore fragmented images")
|
|
17
17
|
.argument("<fragments...>", "Fragment file paths")
|
|
18
|
-
.
|
|
18
|
+
.option("-m, --manifest <path>", "Manifest file path")
|
|
19
19
|
.requiredOption("-o, --output <dir>", "Output directory")
|
|
20
|
+
.option("-b, --block-size <number>", "Block size", Number.parseInt)
|
|
21
|
+
.option("-s, --seed <number>", "Random seed", Number.parseInt)
|
|
22
|
+
.option("-w, --width <number>", "Image width", Number.parseInt)
|
|
23
|
+
.option("-h, --height <number>", "Image height", Number.parseInt)
|
|
20
24
|
.action(handleRestoreCommand);
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
@@ -28,13 +32,41 @@ async function handleRestoreCommand(fragments, options) {
|
|
|
28
32
|
try {
|
|
29
33
|
console.log("🔀 Starting image restoration...");
|
|
30
34
|
const imagePaths = (0, validators_1.validateImagePaths)(fragments);
|
|
31
|
-
const manifestPath = (0, validators_1.validateManifestPath)(options.manifest);
|
|
32
35
|
const outputDir = (0, validators_1.validateOutputDirectory)(options.output);
|
|
33
|
-
|
|
36
|
+
const restoreOptions = {
|
|
34
37
|
imagePaths,
|
|
35
|
-
manifestPath,
|
|
36
38
|
outputDir,
|
|
37
|
-
}
|
|
39
|
+
};
|
|
40
|
+
if (options.manifest) {
|
|
41
|
+
restoreOptions.manifestPath = (0, validators_1.validateManifestPath)(options.manifest);
|
|
42
|
+
}
|
|
43
|
+
else if (options.blockSize !== undefined &&
|
|
44
|
+
options.seed !== undefined &&
|
|
45
|
+
options.width !== undefined &&
|
|
46
|
+
options.height !== undefined) {
|
|
47
|
+
if (imagePaths.length > 1) {
|
|
48
|
+
throw new Error("When using manual options (blockSize, seed, width, height), only a single image can be restored.");
|
|
49
|
+
}
|
|
50
|
+
const { width, height } = options;
|
|
51
|
+
const manifestData = {
|
|
52
|
+
id: "cli-restore",
|
|
53
|
+
version: "0.0.0",
|
|
54
|
+
timestamp: new Date().toISOString(),
|
|
55
|
+
config: {
|
|
56
|
+
blockSize: options.blockSize,
|
|
57
|
+
seed: options.seed,
|
|
58
|
+
prefix: "img",
|
|
59
|
+
preserveName: false,
|
|
60
|
+
crossImageShuffle: false,
|
|
61
|
+
},
|
|
62
|
+
images: [{ w: width, h: height }],
|
|
63
|
+
};
|
|
64
|
+
restoreOptions.manifestData = manifestData;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new Error("Either manifest path or (blockSize, seed, width, height) must be provided.");
|
|
68
|
+
}
|
|
69
|
+
await node_1.default.restore(restoreOptions);
|
|
38
70
|
console.log(`✅ Images restored successfully to: ${outputDir}`);
|
|
39
71
|
}
|
|
40
72
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../src/commands/restore.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"restore.js","sourceRoot":"","sources":["../../../src/commands/restore.ts"],"names":[],"mappings":";;;;;AAiBA,wDAYC;AAzBD,wDAAkC;AAGlC,8CAIuB;AAEvB;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,2BAA2B,CAAC;SACxC,QAAQ,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;SACjD,MAAM,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;SACrD,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;SACxD,MAAM,CAAC,2BAA2B,EAAE,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC;SAClE,MAAM,CAAC,qBAAqB,EAAE,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC;SAC7D,MAAM,CAAC,sBAAsB,EAAE,aAAa,EAAE,MAAM,CAAC,QAAQ,CA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,KAAK;iBACzB;gBACD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;aAClC,CAAC;YACF,cAAc,CAAC,YAAY,GAAG,YAAY,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;QACJ,CAAC;QAED,MAAM,cAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAErC,OAAO,CAAC,GAAG,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAClF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixzle/cli",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "CLI implementation of image fragmentation and restoration
|
|
3
|
+
"version": "0.0.21",
|
|
4
|
+
"description": "CLI implementation of image fragmentation and restoration",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"commander": "^12.1.0",
|
|
27
|
-
"@pixzle/
|
|
28
|
-
"@pixzle/
|
|
27
|
+
"@pixzle/node": "0.0.21",
|
|
28
|
+
"@pixzle/core": "0.0.21"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.10.1",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc -p tsconfig.build.json",
|
|
38
38
|
"build:check": "tsc -p tsconfig.build.json --noEmit",
|
|
39
|
-
"test": "vitest",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest",
|
|
40
41
|
"dev": "tsx src/cli.ts"
|
|
41
42
|
}
|
|
42
43
|
}
|