# get-pixels

> Reads the pixels of an image as an ndarray

Latest version **3.3.3** (published 2021-07-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-pixels
pnpm add get-pixels
yarn add get-pixels
bun add get-pixels
```

## 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 | 3.3.3 |
| Published | 2021-07-15 |
| First published | 2013-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/get-pixels) |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 551 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko, jaspervdg, hughsk, substack, planeshifter, rreusser |
| Keywords | ndarray, pixel, get, read, pixel, image, png, jpeg, jpg, jpe, gif, decode, buffer, data, parse, dom, node, browserify |

## Links

- npm: https://www.npmjs.com/package/get-pixels
- Repository: https://github.com/scijs/get-pixels
- Homepage: https://github.com/scijs/get-pixels#readme
- Issues: https://github.com/scijs/get-pixels/issues
- npm.io page: https://npm.io/package/get-pixels

## Dependencies (11)

- [pngjs](https://npm.io/package/pngjs.md) ^3.3.3
- [omggif](https://npm.io/package/omggif.md) ^1.0.5
- [jpeg-js](https://npm.io/package/jpeg-js.md) ^0.4.1
- [ndarray](https://npm.io/package/ndarray.md) ^1.0.13
- [request](https://npm.io/package/request.md) ^2.44.0
- [through](https://npm.io/package/through.md) ^2.3.4
- [mime-types](https://npm.io/package/mime-types.md) ^2.0.1
- [node-bitmap](https://npm.io/package/node-bitmap.md) 0.0.1
- [ndarray-pack](https://npm.io/package/ndarray-pack.md) ^1.1.1
- [parse-data-uri](https://npm.io/package/parse-data-uri.md) ^0.2.0
- [data-uri-to-buffer](https://npm.io/package/data-uri-to-buffer.md) 0.0.3

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 3.3.3 (latest) — 2021-07-15
- 3.3.2 — 2018-07-11
- 3.3.0 — 2016-02-22
- 3.2.3 — 2015-09-08
- 3.2.2 — 2015-04-17
- 3.2.1 — 2015-03-29
- 3.2.0 — 2015-03-22
- 3.1.1 — 2015-02-06
- 3.1.0 — 2014-11-12
- 3.0.1 — 2014-09-22
- 3.0.0 — 2014-09-22
- 2.0.0 — 2014-09-22
- 1.1.3 — 2014-09-13
- 1.1.2 — 2014-09-10
- 1.1.0 — 2014-04-19
- … 7 more at https://npm.io/package/get-pixels/versions

## README

get-pixels
==========
Given a URL/path, grab all the pixels in an image and return the result as an [ndarray](https://github.com/mikolalysenko/ndarray).  Written in 100% JavaScript, works both in browserify and in node.js and has no external native dependencies.

Currently the following file formats are supported:

* `PNG`
* `JPEG`
* `GIF`

Example
=======

```javascript
var getPixels = require("get-pixels")

getPixels("lena.png", function(err, pixels) {
  if(err) {
    console.log("Bad image path")
    return
  }
  console.log("got pixels", pixels.shape.slice())
})
```

Install
=======

    npm install get-pixels

### `require("get-pixels")(url[, type], cb(err, pixels))`
Reads all the pixels from url into an ndarray.

* `url` is the path to the file.  It can be a relative path, an http url, a data url, or an [in-memory Buffer](http://nodejs.org/api/buffer.html).
* `type` is an optional mime type for the image (required when using a Buffer)
* `cb(err, pixels)` is a callback which gets triggered once the image is loaded.

**Returns** An ndarray of pixels in raster order having shape equal to `[width, height, channels]`.

**Note** For animated GIFs, a 4D array is returned with shape `[numFrames, width, height, 4]`, where each frame is a slice of the final array.

Credits
=======
(c) 2013-2014 Mikola Lysenko. MIT License

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