# multer-sharp-storage

> Multer storage with sharp image processor

Latest version **1.1.0** (published 2020-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install multer-sharp-storage
pnpm add multer-sharp-storage
yarn add multer-sharp-storage
bun add multer-sharp-storage
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-02-04 |
| First published | 2019-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | kguevara |
| Keywords | multer, sharp, image, storage engine |

## Links

- npm: https://www.npmjs.com/package/multer-sharp-storage
- Repository: https://github.com/kguevara/multer-sharp-storage
- Issues: https://github.com/kguevara/multer-sharp-storage/issues
- npm.io page: https://npm.io/package/multer-sharp-storage

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [sharp](https://npm.io/package/sharp.md) ^0.24.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.3
- [concat-stream](https://npm.io/package/concat-stream.md) ^2.0.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

- 1.1.0 (latest) — 2020-02-04
- 1.0.1 — 2019-04-11
- 1.0.0 — 2019-04-11

## README

# Multer-Sharp-Storage

***

Multer-Sharp-Storage is a multer storage engine that allows you to transform the image and store it on the disk.

This project is mostly an integration piece for existing code samples from Multer [storage engine documentation](https://github.com/expressjs/multer/blob/master/StorageEngine.md). With add-ons include  [sharp](https://github.com/lovell/sharp)


# Installation

npm:

	npm install --save multer-sharp-storage

yarn:

	yarn add multer-sharp-storage

# Tests

```
npm test
```

# Usage

```javascript
const express = require('express');
const multer = require('multer');
const sharpStorage = require('multer-sharp-storage');

const app = express();

const storage = sharpStorage({
	output: 'png',
	quality: 90,
	sharpMiddleware: function (sharp) {
		sharp.resize({width: 40, height: 80});
		return sharp;
	},
	destination: function (req, file, cb) {
		cb(null, 'storage/uploads')
	},
	filename: function (req, file, cb) {
		cb(null, file.fieldname + '-' + Date.now())
	}
});

var limits = {
	files: 10,
	fileSize: 1024 * 1024 * 10,
};

const upload = multer({ 
    storage,
    limits
});

app.post('/upload', upload.single('image'), (req, res) => {
    console.log(req.file); // Print upload details
    res.send('Successfully uploaded!');
});

```

for more example you can see [here](https://github.com/kguevara/multer-sharp-storage)

# Options
```javascript
const storage = sharpStorage(options);
```

#### Multer-Sharp options
| option | default |  |
| ------ | ------- | ---- |
| output | jpg | your output format |
| quality | 70 | your output quality |
| destination | `storage/uploads` | your output destination |
| filename | randomString | your output filename |

***

## License
[MIT](http://opensource.org/licenses/MIT)
Copyright (c) 2019 - forever [Kelwin Guevara](https://github.com/kguevara)

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