# impro

> Image processing engine

Latest version **0.14.3** (published 2025-03-01) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install impro
pnpm add impro
yarn add impro
bun add impro
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.14.3 |
| Published | 2025-03-01 |
| First published | 2018-03-24 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 97 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Andreas Lind |
| Maintainers | alexjeffburke, papandreou |
| Keywords | image, processing, resize, rotate |

## Links

- npm: https://www.npmjs.com/package/impro
- Repository: https://github.com/papandreou/impro
- Homepage: https://github.com/papandreou/impro#readme
- Issues: https://github.com/papandreou/impro/issues
- npm.io page: https://npm.io/package/impro

## Dependencies (3)

- [icc](https://npm.io/package/icc.md) ^3.0.0
- [mime](https://npm.io/package/mime.md) ^3.0.0
- [exif-reader](https://npm.io/package/exif-reader.md) ^1.0.3

## 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

- 0.14.3 (latest) — 2025-03-01
- 0.14.2 — 2023-12-18
- 0.14.1 — 2023-12-17
- 0.14.0 — 2023-12-16
- 0.13.1 — 2023-10-27
- 0.13.0 — 2022-03-15
- 0.12.0 — 2022-03-15
- 0.11.0 — 2021-09-21
- 0.10.0 — 2021-05-12
- 0.9.0 — 2021-01-20
- 0.8.0 — 2020-09-04
- 0.7.2 — 2020-08-30
- 0.7.1 — 2020-05-21
- 0.7.0 — 2020-04-09
- 0.6.1 — 2020-02-18
- … 11 more at https://npm.io/package/impro/versions

## README

# Impro

An image processing engine integrating multiple conversion libraries.

[![NPM version](https://badge.fury.io/js/impro.svg)](http://badge.fury.io/js/impro)
[![Build Status](https://github.com/papandreou/impro/workflows/tests/badge.svg)](https://github.com/papandreou/impro/actions)
[![Coverage Status](https://coveralls.io/repos/papandreou/impro/badge.svg)](https://coveralls.io/r/papandreou/impro)

Impro allows specifying the operations to apply to images and will
select the correct conversion library to perform the job itself.

This library supports and is tested against node version **14** and above and
includes support for the following image conversion tools:

<!-- evaldown output:true -->

```
- gifsicle (npm install gifsicle@^5.3.0)
- gm (npm install gm-papandreou@^1.23.0-patch1)
- inkscape (npm install inkscape@^3.0.0)
- jpegtran (npm install jpegtran@^2.0.0)
- optipng (npm install optipng@^4.0.0)
- pngcrush (npm install pngcrush@^3.0.0)
- pngquant (npm install pngquant@^4.0.0)
- sharp (npm install sharp@~0.32.0)
- svgfilter (npm install svgfilter@^4.1.0)
```

> callers must install the libraries and if present they will be enabled

## Introduction

Impro is desgined so that users can express what they want to do to an image
of a given type rather than how to do it. Given a series of tranformations,
the library will select one or more libraries to use to turn the input image
into the desired output and processing is done while fully streaming data.

## Background

Image processing has typically involved command line tools which are often
supplied a set of command line arguments that act as a series of instructions
for the properties of the image being output and any series of transformations
to apply. Each of these options is modelled as an "operation".

### Operations

An operation is a named constraint (property or transformation) that an
_output image_ must conform to after it is applied.

### Engines

An engine is a representation a particular image library that supports a
certain set of operations on images of certain types.

### Pipelines

A pipeline is a programmed series operations that will be executed by
one or more engines to turn an image from the input to the desired output.

## Use

The `impro` library can be installed simply from npm:

```
npm install impro
```

The standard configuration of impro is an instance that is configured with
support for all supported engines - but the presence of the image libraries
is detected which means they must be installed alongside. Each library has
a node module of the same name (with the exception of gm as noted above):

```
npm install sharp
npm install gifsicle
```

> some of the libraries may have requirements on native packages
> that must be installed via an operating system package manager

## Constructing image processing pipelines

By default an import of impro returns an object with all registered engines
that is ready to start handling conversion operations. To do this, we create
a pipeline which we instruct about what it will do to an image.

The prepared pipeline is a Duplex stream that is ready to have the input image
data piped to it and will stream the output image data out of itself:

```js
const impro = require('impro');

const pipeline = impro.createPipeline({ type: 'png' }).jpeg();
```

For example, the pipeline above expect to recieve a PNG input image and
will convert it to a JPEG using the _chaining API_.

### Chaining API

The pipeline exposes methods for each operation that can be supported on a
method. Above, the `.jpeg()` is a conversion operation to the JPEG type.

Let's look at another example:

```js
const impro = require('impro');

impro
  .createPipeline({ type: 'png' })
  .grayscale()
  .resize(100, 100)
  .jpeg()
  .progressive();
```

This will accept a PNG, convert it to a grayscale image, resize it and finally
output it as a JPEG that is interlaced. The chaining API is intended as the
standard end-user interface that exposes the full power of the library in a
simple and transparent fashion.

### Low-level API

For cases where impro is used as a library another API is exposed which is
also used internally and underlies chaining methods: an operations list.

Each named operation is itself a small object containing a name and array
of the arguments (zero or more) that are provided to it. These operations
are placed in an array and can be passed directly when creating a pipeline:

```js
const impro = require('impro');

const pipeline = impro.createPipeline({ type: 'png' }, [
  { name: 'grayscale', args: [] },
  { name: 'resize', args: [100, 100] },
  { name: 'jpeg', args: [] },
  { name: 'progressive', args: [] },
]);
```

The pipeline above is equivalent to the chaining API example.

## License

Impro is licensed under a standard 3-clause BSD license.

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