@mantiqh/image-optimizer 1.0.0 → 1.0.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/index.js +25 -1
- package/package.json +1 -1
- package/src/index.ts +27 -2
package/dist/index.js
CHANGED
|
@@ -9,7 +9,31 @@ import sharp from "sharp";
|
|
|
9
9
|
import chalk from "chalk";
|
|
10
10
|
import ora from "ora";
|
|
11
11
|
var program = new Command();
|
|
12
|
-
program.name("image-optimizer").description(
|
|
12
|
+
program.name("image-optimizer").description(
|
|
13
|
+
chalk.cyan(
|
|
14
|
+
"\u{1F680} CLI to optimize images (JPEG, PNG, WebP) inside a zip file recursively."
|
|
15
|
+
)
|
|
16
|
+
).version("1.0.0").requiredOption("-s, --source <path>", "Path to the input zip file").option(
|
|
17
|
+
"-o, --output <path>",
|
|
18
|
+
"Path to the output zip file (defaults to [name]-optimized.zip)"
|
|
19
|
+
).option("-q, --quality <number>", "Quality of compression (1-100)", "80").option("-w, --width <number>", "Max width to resize images to", "1600").addHelpText(
|
|
20
|
+
"after",
|
|
21
|
+
`
|
|
22
|
+
${chalk.yellow("Examples:")}
|
|
23
|
+
${chalk.green("$ npx @mantiqh/image-optimizer --source assets.zip")}
|
|
24
|
+
${chalk.gray(
|
|
25
|
+
"# Optimizes assets.zip and saves as assets-optimized.zip (default settings)"
|
|
26
|
+
)}
|
|
27
|
+
|
|
28
|
+
${chalk.green(
|
|
29
|
+
"$ npx @mantiqh/image-optimizer -s ./raw.zip -o ./final.zip -q 90"
|
|
30
|
+
)}
|
|
31
|
+
${chalk.gray("# Optimizes raw.zip to final.zip with 90% quality")}
|
|
32
|
+
|
|
33
|
+
${chalk.green("$ npx @mantiqh/image-optimizer -s huge-images.zip -w 800")}
|
|
34
|
+
${chalk.gray("# Resizes all images to max 800px width")}
|
|
35
|
+
`
|
|
36
|
+
).parse(process.argv);
|
|
13
37
|
var options = program.opts();
|
|
14
38
|
async function main() {
|
|
15
39
|
const spinner = ora("Starting optimization...").start();
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,12 +11,37 @@ const program = new Command();
|
|
|
11
11
|
|
|
12
12
|
program
|
|
13
13
|
.name("image-optimizer")
|
|
14
|
-
.description(
|
|
14
|
+
.description(
|
|
15
|
+
chalk.cyan(
|
|
16
|
+
"🚀 CLI to optimize images (JPEG, PNG, WebP) inside a zip file recursively."
|
|
17
|
+
)
|
|
18
|
+
)
|
|
15
19
|
.version("1.0.0")
|
|
16
20
|
.requiredOption("-s, --source <path>", "Path to the input zip file")
|
|
17
|
-
.option(
|
|
21
|
+
.option(
|
|
22
|
+
"-o, --output <path>",
|
|
23
|
+
"Path to the output zip file (defaults to [name]-optimized.zip)"
|
|
24
|
+
)
|
|
18
25
|
.option("-q, --quality <number>", "Quality of compression (1-100)", "80")
|
|
19
26
|
.option("-w, --width <number>", "Max width to resize images to", "1600")
|
|
27
|
+
.addHelpText(
|
|
28
|
+
"after",
|
|
29
|
+
`
|
|
30
|
+
${chalk.yellow("Examples:")}
|
|
31
|
+
${chalk.green("$ npx @mantiqh/image-optimizer --source assets.zip")}
|
|
32
|
+
${chalk.gray(
|
|
33
|
+
"# Optimizes assets.zip and saves as assets-optimized.zip (default settings)"
|
|
34
|
+
)}
|
|
35
|
+
|
|
36
|
+
${chalk.green(
|
|
37
|
+
"$ npx @mantiqh/image-optimizer -s ./raw.zip -o ./final.zip -q 90"
|
|
38
|
+
)}
|
|
39
|
+
${chalk.gray("# Optimizes raw.zip to final.zip with 90% quality")}
|
|
40
|
+
|
|
41
|
+
${chalk.green("$ npx @mantiqh/image-optimizer -s huge-images.zip -w 800")}
|
|
42
|
+
${chalk.gray("# Resizes all images to max 800px width")}
|
|
43
|
+
`
|
|
44
|
+
)
|
|
20
45
|
.parse(process.argv);
|
|
21
46
|
|
|
22
47
|
const options = program.opts();
|