npm install resize-image-buffer
yarn add resize-image-buffer
const fs = require('fs');
const resizeImg = require('resize-image-buffer');
(async () => {
const image = await resizeImg(fs.readFileSync('unicorn.png'), {
width: 128,
height: 128,
});
fs.writeFileSync('unicorn-128x128.png', image);
})();
Returns a Promise<Buffer>
with the resized image.
Type: Buffer
An image buffer. Supported formats are bmp
, jpg
and png
.
Type: Object
Type: number
Desired width of the target image.
Type: number
Desired height of the target image.
Type: string
The output file format for the target image. Supported formats are bmp
, jpg
and png
.