# js-image-lib

> An image manipulation library using only pure JavaScript

Latest version **1.0.1** (published 2022-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-image-lib
pnpm add js-image-lib
yarn add js-image-lib
bun add js-image-lib
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-06-24 |
| First published | 2022-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 7 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Josh McFarlin |
| Maintainers | josh-mcfarlin |
| Keywords | image, manipulation, transformation |

## Links

- npm: https://www.npmjs.com/package/js-image-lib
- Repository: https://github.com/Josh-McFarlin/js-image-lib
- Homepage: https://js-image-lib.mcfarl.in
- Issues: https://github.com/Josh-McFarlin/js-image-lib/issues
- npm.io page: https://npm.io/package/js-image-lib

## Dependencies (7)

- [omggif](https://npm.io/package/omggif.md) ^1.0.10
- [jpeg-js](https://npm.io/package/jpeg-js.md) ^0.4.4
- [mime-tree](https://npm.io/package/mime-tree.md) ^0.1.4
- [decode-tiff](https://npm.io/package/decode-tiff.md) ^0.2.1
- [@pdf-lib/upng](https://npm.io/package/@pdf-lib/upng.md) ^1.0.1
- [@wokwi/bmp-ts](https://npm.io/package/@wokwi/bmp-ts.md) ^3.0.0
- [get-rgba-palette](https://npm.io/package/get-rgba-palette.md) ^2.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-06-24
- 1.0.0 — 2022-06-24
- 0.2.0 — 2022-06-21
- 0.1.7 — 2022-03-29
- 0.1.6 — 2022-02-23
- 0.1.5 — 2022-02-18
- 0.1.4 — 2022-02-18
- 0.1.3 — 2022-02-17
- 0.1.2 — 2022-02-17
- 0.1.1 — 2022-02-17

## README

# js-image-lib

![](https://badgen.net/npm/v/js-image-lib)
![](https://badgen.net/npm/license/js-image-lib)
![](https://badgen.net/npm/types/js-image-lib)
![](https://badgen.net/bundlephobia/min/js-image-lib)
![](https://badgen.net/npm/dt/js-image-lib)

## 👋 Intro

An image manipulation library using only pure JavaScript

This library lets you:
* Resize images to different sizes
* Convert between the following file types: `png`, `jpeg`, `gif`, `bmp`, and `tiff`
* Apply operations like `resize`, `crop`, `rotate`, `blur`, and `flip`

This library uses pure browser-compatible JavaScript, relying on no Node packages.
This means js-image-lib can be run anywhere you use JavaScript!

**Note**: The use of pure JavaScript means this library will run much slower
than alternative libraries that have C/etc bindings. You should primarily use js-image-lib
in environments where speed is not the first concern, especially in cases where you are trying to support all platforms!

## 🚀 How to use

### Install

To install this library, use on of the following commands:
```bash
npm install -S js-image-lib
yarn add js-image-lib
```

### Use

Retrieve your image as a Uint8Array, then transform it with `imageTransformer` by providing the image and the options to use.

```typescript jsx
import ImageTransformer from "js-image-lib";

// Get your image to transform on Node
const inputJpeg = new Uint8Array(fs.readFileSync("./my-image.jpeg"));

// Or get your image to transform in the browser using fetch
const imageResponse = await fetch(url, {
  headers: {
    accept: "image/*",
  },
});
const arrBuff = await imageResponse.arrayBuffer();
const inputJpeg = new Uint8Array(arrBuff);

// Create ImageTransformer with your image
const transformer = new ImageTransformer(inputJpeg);

transformer.blur(...);
transformer.crop(...);
transformer.flip(...);
transformer.resize(...);
transformer.rotate(...);

// Operations can be done in sequence
transformer.blur(5).rotate(45).flip("both");

// Finally, export your image
const exported = transformer.toBuffer("image/jpeg");
```

## Docs

- Documentation for this library can be found at: [https://js-image-lib.mcfarl.in](https://js-image-lib.mcfarl.in)
- Several examples can be found in [examples/](examples/)

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