[BEEEP] Add script for optimizing images (#1374)
|
@ -101,6 +101,7 @@
|
||||||
"npm": "~8"
|
"npm": "~8"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*": "prettier --ignore-unknown --write"
|
"*": "prettier --ignore-unknown --write",
|
||||||
|
"*.png": "node scripts/optimize.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
const child_process = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const images = process.argv.slice(2);
|
||||||
|
|
||||||
|
images.forEach((img) => {
|
||||||
|
switch (img.split(".").pop()) {
|
||||||
|
case "png":
|
||||||
|
child_process.execSync(
|
||||||
|
`npx @squoosh/cli --oxipng {} --output-dir "${path.dirname(img)}" "${img}"`
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "jpg":
|
||||||
|
child_process.execSync(
|
||||||
|
`npx @squoosh/cli --mozjpeg {"quality":85,"baseline":false,"arithmetic":false,"progressive":true,"optimize_coding":true,"smoothing":0,"color_space":3,"quant_table":3,"trellis_multipass":false,"trellis_opt_zero":false,"trellis_opt_table":false,"trellis_loops":1,"auto_subsample":true,"chroma_subsample":2,"separate_chroma_quality":false,"chroma_quality":75} --output-dir "${path.dirname(
|
||||||
|
img
|
||||||
|
)}" "${img}"`
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 434 B |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 950 B |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 352 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 174 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 18 KiB |