bear-node-imagemin
v1.0.5
Published
imagemin + sharp Nodejs image processing tool
Downloads
41
Maintainers
Readme
bear-node-imagemin
- If you don't want to worry about the problems imagemin encounters in the runtime environment,
You can use
Docker image
(bear-imagemin-server) +npm package
(bear-imagemin-client) directly - If you want to use it directly in the project, just install
bear-node-imagemin
directly
Install
yarn add -D bear-node-imagemin
How to use
import {lossySquash, losslessSquash} from 'bear-node-imagemin';
const isLossLess = false;
const sourceFile = './example/static/source.png';
const params = {
quality: isLossLess ? undefined: quality,
resize: {width: 200, height: 200, ignoreOverflowSize: true},
extname: 'webp',
};
// file to buff
const bufferData = fs.readFileSync(sourceFile);
const newBuff = isLossLess ?
await losslessSquash(bufferData, params): // is lossLess
await lossySquash(bufferData, params); // is lossy
fs.writeFileSync('./example/static/lossySquash/image_1024.png', newBuff);
Use Docker Server + Client
see packages/bear-imagemin-server
and packages/bear-imagemin-client
Use CLI
see packages/bear-imagemin-cli
Release
in root dir
$ yarn build
$ npm publish --access=public
Document
License
MIT © imagine10255