-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
328 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env node | ||
import process from 'node:process'; | ||
import {spawn} from 'node:child_process'; | ||
import binPath from './index.js'; | ||
|
||
spawn(binPath, process.argv.slice(2), {stdio: 'inherit'}) | ||
.on('exit', process.exit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import lib from './lib/index.js'; | ||
|
||
export default lib.path(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import binBuild from 'bin-build'; | ||
import bin from './index.js'; | ||
|
||
bin.run(['-version']).then(() => { | ||
console.log('cwebp pre-build test passed successfully'); | ||
}).catch(error => { | ||
console.warn(error.message); | ||
console.warn('cwebp pre-build test failed'); | ||
console.info('compiling from source'); | ||
|
||
try { | ||
const source = fileURLToPath(new URL('../vendor/source/libwebp-1.2.1.tar.gz', import.meta.url)); | ||
|
||
binBuild.file(source, [ | ||
`./configure --disable-shared --prefix="${bin.dest()}" --bindir="${bin.dest()}"`, | ||
'make && make install', | ||
]); | ||
|
||
console.log('cwebp built successfully'); | ||
} catch (error) { | ||
console.error(error.stack); | ||
|
||
// eslint-disable-next-line unicorn/no-process-exit | ||
process.exit(1); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) Imagemin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "cwebp-bin", | ||
"version": "8.0.0", | ||
"description": "cwebp wrapper that makes it seamlessly available as a local dependency", | ||
"license": "MIT", | ||
"repository": "imagemin/cwebp-bin", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"funding": "https://github.com/imagemin/cwebp-bin?sponsor=1", | ||
"bin": { | ||
"cwebp": "cli.js" | ||
}, | ||
"engines": { | ||
"node": "^14.13.1 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"postinstall": "node lib/install.js", | ||
"test": "xo && ava --timeout=180s" | ||
}, | ||
"files": [ | ||
"cli.js", | ||
"index.js", | ||
"lib", | ||
"vendor/source" | ||
], | ||
"keywords": [ | ||
"imagemin", | ||
"compress", | ||
"image", | ||
"img", | ||
"jpeg", | ||
"jpg", | ||
"minify", | ||
"optimize", | ||
"png", | ||
"webp" | ||
], | ||
"dependencies": { | ||
"bin-build": "^3.0.0", | ||
"bin-wrapper": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^4.2.0", | ||
"bin-check": "^4.1.0", | ||
"compare-size": "^3.0.0", | ||
"execa": "^6.1.0", | ||
"tempy": "^3.0.0", | ||
"xo": "^0.48.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# cwebp-bin  | ||
|
||
> [WebP](https://developers.google.com/speed/webp/) is a new image format that provides lossless and lossy compression for images on the web. WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller in size compared to JPEG images at equivalent SSIM index. | ||
You probably want [`imagemin-webp`](https://github.com/imagemin/imagemin-webp) instead. | ||
|
||
|
||
## Install | ||
|
||
``` | ||
$ npm install cwebp-bin | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
```js | ||
import {execFile} from 'node:child_process'; | ||
import cwebp from 'cwebp-bin'; | ||
|
||
execFile(cwebp, ['input.png', '-o', 'output.webp'], err => { | ||
if (err) { | ||
throw err; | ||
} | ||
|
||
console.log('Image is converted!'); | ||
}); | ||
``` | ||
|
||
|
||
## CLI | ||
|
||
``` | ||
$ npm install --global cwebp-bin | ||
``` | ||
|
||
``` | ||
$ cwebp --help | ||
``` | ||
|
||
|
||
## License | ||
|
||
MIT © [Imagemin](https://github.com/imagemin) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env node | ||
import {spawn} from 'node:child_process'; | ||
import process from 'node:process'; | ||
import mozjpeg from './index.js'; | ||
|
||
const input = process.argv.slice(2); | ||
|
||
spawn(mozjpeg, input, {stdio: 'inherit'}) | ||
.on('exit', process.exit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import lib from './lib/index.js'; | ||
|
||
export default lib.path(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os from 'node:os'; | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import binBuild from 'bin-build'; | ||
import bin from './index.js'; | ||
|
||
const cpuNumber = Math.max(os.cpus().length, 1); | ||
|
||
bin.run(['-version']).then(() => { | ||
console.log('mozjpeg pre-build test passed successfully'); | ||
}).catch(async error => { | ||
console.warn(error.message); | ||
console.warn('mozjpeg pre-build test failed'); | ||
console.info('compiling from source'); | ||
|
||
let cfgExtras = ''; | ||
if (process.platform === 'darwin') { | ||
cfgExtras = 'libpng_LIBS=\'/usr/local/lib/libpng16.a -lz\' --enable-static'; | ||
} | ||
|
||
const cfg = [ | ||
`./configure --enable-static --disable-shared --disable-dependency-tracking --with-jpeg8 ${cfgExtras}`, | ||
`--prefix="${bin.dest()}" --bindir="${bin.dest()}" --libdir="${bin.dest()}"`, | ||
].join(' '); | ||
|
||
try { | ||
const source = fileURLToPath(new URL('../vendor/source/mozjpeg.tar.gz', import.meta.url)); | ||
await binBuild.file(source, [ | ||
'autoreconf -fiv', | ||
cfg, | ||
`make -j${cpuNumber}`, | ||
`make install -j${cpuNumber}`, | ||
]); | ||
|
||
console.log('mozjpeg built successfully'); | ||
} catch (error) { | ||
console.error(error.stack); | ||
|
||
// eslint-disable-next-line unicorn/no-process-exit | ||
process.exit(1); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) Imagemin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Oops, something went wrong.