# simple-web-image

> A simple library to process the image in many sizes for the website.

Latest version **2.0.0** (published 2022-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-web-image
pnpm add simple-web-image
yarn add simple-web-image
bun add simple-web-image
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-12-09 |
| First published | 2022-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.15.0 |
| Dependencies | 2 |
| Unpacked size | 33.1 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Vu Lai |
| Maintainers | cookievu |
| Keywords | image process, image compare, image resize, seo image |

## Links

- npm: https://www.npmjs.com/package/simple-web-image
- Repository: https://github.com/tuanvu0995/simple-web-image
- Homepage: https://github.com/tuanvu0995/simple-web-image#readme
- Issues: https://github.com/tuanvu0995/simple-web-image/issues
- npm.io page: https://npm.io/package/simple-web-image

## Dependencies (2)

- [sharp](https://npm.io/package/sharp.md) ^0.30.7
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.1218.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) — 2022-12-09
- 1.0.9 — 2022-09-18
- 1.0.8 — 2022-09-07
- 1.0.7 — 2022-09-06
- 1.0.6 — 2022-09-06
- 1.0.5 — 2022-09-06
- 1.0.4 — 2022-09-05
- 1.0.3 — 2022-09-05
- 1.0.2 — 2022-09-05
- 1.0.1 — 2022-09-02
- 1.0.0 — 2022-09-02

## README

[![npm version](https://badge.fury.io/js/simple-web-image.svg)](https://badge.fury.io/js/simple-web-image)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# simple-web-image

> A simple library to process the image to many sizes for the website.

# Features
* Optimize the image size and quality of the website.
* Resize images to different sizes to use for desktop and mobile. It works better for the lazy load.
* Store the output locally or in the cloud storage (ext: s3, minio, ...).

## Prerequisites

This project requires NodeJS (version 14 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

```sh
$ npm -v && node -v
6.4.1
v14.15.0
```

## Getting Started


```sh
npm install simple-web-image
```

### Basic usage:
```typescript

import SimpleWebImage from 'simple-web-image'

const config = {
    drives: {
        local: { rootDir: './tmp/output/simple-web-image' },
        s3: {
            accessKeyId: "THE AWS ACCESS KEY ID",
            secretAccessKey: "THE AWS SECRET ACCESS KEY",
            bucket: "simple-web-image",
            region: "us-east-1"
        }
    }
}

const simple = new SimpleWebImage(config)

try {
    await simple.drive('local').put(req, './tmp/output/simple-web-image/image-name')
    await simple.drive('s3').put(req, './tmp/output/simple-web-image/image-name')
} catch (error) {
    // code here
}
```


### Using with `expressjs`:
```typescript

import express from "express"
import SimpleWebImage from "simple-web-image"
const app = express()
const port = 3000

const config = {}

const simple = new SimpleWebImage(config)

// should upload with binary body
app.post("/upload", async (req, res) => {
  try {
    await simple.drive('local').put(req, './tmp/output/simple-web-image/image-name')
    res.send("upload success")
  } catch (err) {
    res.send("upload fail")
  }
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})
```

Look at the [example](https://github.com/tuanvu0995/swi-example.git) repo for more details.

## Contributing

Any contributions from the community are welcome.

Find a bug, a typo, or something that’s not documented well? We’d love for you to open an issue telling us what we can improve! Follow the [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

We love your pull requests! Check out our Good First Issue and Help Wanted tags for good issues to tackle. Check out our contributors guide for more information.

If you like what you see, star us on GitHub

## Roadmap

See the [ROADMAP.md](ROADMAP.md) file

## License

[MIT License](LICENSE) © Vu Lai

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