Merge upstream

This commit is contained in:
Jason Miller
2020-12-10 10:24:56 -05:00
parent a2fb7a38cd
commit d1d181fccd
26 changed files with 358 additions and 29 deletions

BIN
cli/.DS_Store vendored

Binary file not shown.

1
cli/.gitignore vendored
View File

@@ -1,2 +1,3 @@
node_modules
build
.DS_Store

View File

@@ -47,7 +47,7 @@ The default values for each `config` option can be found in the [`codecs.js`][co
Squoosh CLI has an _experimental_ auto optimizer that compresses an image as much as possible, trying to hit a specific [Butteraugli] target value. The higher the Butteraugli target value, the more artifacts can be introduced.
You can make use of the auto optimizer buy using “auto” as the config object.
You can make use of the auto optimizer by using “auto” as the config object.
```
$ npx @squoosh/cli --wp2 auto test.png

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

2
cli/package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@squoosh/cli",
"version": "0.5.0",
"version": "0.6.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@squoosh/cli",
"version": "0.5.0",
"version": "0.6.0",
"description": "A CLI for Squoosh",
"public": true,
"bin": {

View File

@@ -4,6 +4,7 @@ import { isMainThread } from 'worker_threads';
import { cpus } from 'os';
import { extname, join, basename } from 'path';
import { promises as fsp } from 'fs';
import { resolve as resolvePath } from 'path';
import { version } from 'json:../package.json';
import ora from 'ora';
import kleur from 'kleur';
@@ -182,7 +183,32 @@ function progressTracker(results) {
return tracker;
}
async function checkInputFilesValid(files) {
const validFiles = [];
for (const file of files) {
try {
await fsp.stat(file);
} catch (err) {
if (err.code === 'ENOENT') {
console.warn(
`Warning: Input file does not exist: ${resolvePath(file)}`,
);
continue;
} else {
throw err;
}
}
validFiles.push(file);
}
return validFiles;
}
async function processFiles(files) {
files = await checkInputFilesValid(files);
const parallelism = cpus().length;
const results = new Map();

File diff suppressed because one or more lines are too long