| 123456789 |
- const Jimp = require('jimp');
- const [input, out, x, y, width, height, outputWidth] = process.argv.slice(2);
- (async () => {
- const image = await Jimp.read(input);
- const part = image.crop(+x, +y, +width, +height);
- if (outputWidth) part.resize(+outputWidth, Jimp.AUTO);
- await part.writeAsync(out);
- console.log(`${input}: crop ${x},${y},${width},${height} -> ${out} (${part.bitmap.width}x${part.bitmap.height})`);
- })().catch(e => { console.error(e); process.exitCode = 1; });
|