# resize-img

> Resize images in memory

Latest version **2.0.0** (published 2019-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install resize-img
pnpm add resize-img
yarn add resize-img
bun add resize-img
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-09-19 |
| First published | 2016-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/resize-img) |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kevin Martensson |
| Maintainers | kevva |
| Keywords | bmp, fast, image, jpeg, jpg, memory, png, resize |

## Links

- npm: https://www.npmjs.com/package/resize-img
- Repository: https://github.com/kevva/resize-img
- Homepage: https://github.com/kevva/resize-img#readme
- Issues: https://github.com/kevva/resize-img/issues
- npm.io page: https://npm.io/package/resize-img

## Dependencies (2)

- [jimp](https://npm.io/package/jimp.md) ^0.8.3
- [file-type](https://npm.io/package/file-type.md) ^12.3.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-09-19
- 1.1.2 — 2016-10-31
- 1.1.1 — 2016-09-13
- 1.1.0 — 2016-04-18
- 1.0.0 — 2016-04-18

## README

# resize-img [![Build Status](https://travis-ci.org/kevva/resize-img.svg?branch=master)](https://travis-ci.org/kevva/resize-img)

> Resize images in memory


## Install

```
$ npm install resize-img
```


## Usage

```js
const fs = require('fs');
const resizeImg = require('resize-img');

(async () => {
	const image = await resizeImg(fs.readFileSync('unicorn.png'), {
		width: 128,
		height: 128
	});

	fs.writeFileSync('unicorn-128x128.png', image);
})();
```


## API

### resizeImg(buffer, options)

Returns a `Promise<Buffer>` with the resized image.

#### buffer

Type: `Buffer`

An image buffer. Supported formats are `bmp`, `jpg` and `png`.

#### options

Type: `Object`

##### width

Type: `number`

Desired width of the target image.

##### height

Type: `number`

Desired height of the target image.

##### format

Type: `string`

The output file format for the target image. Supported formats are `bmp`, `jpg` and `png`.


## Related

* [resize-img-cli](https://github.com/kevva/resize-img-cli) - CLI for this module.

---
_Source: https://npm.io/package/resize-img · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
