JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 306
  • Score
    100M100P100Q97676F
  • License MIT

An image parser that works.

Package Exports

  • image-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (image-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

image-parser

image-parser

PayPal AMA Version Downloads Get help on Codementor

An image parser that works.

This library uses lwip to parse the images falling back to GraphicsMagick. 🎨

☁️ Installation

$ npm i --save image-parser

πŸ“‹ Example

const ImageParser = require("image-parser");

let img = new ImageParser("https://octodex.github.com/images/privateinvestocat.jpg");
img.parse(err => {
    if (err) { return console.error(err); }
    console.log(img.getPixel(3, 3));
    // PixelClass { r: 34, g: 30, b: 31, a: 1 }
});

πŸ“ Documentation

ImageParser(source, options)

Creates a new instance of ImageParser.

Params

  • String|Buffer source: The image path/url or the a Buffer object.
  • Object options: The options object to pass to the lwipify.

Return

  • ImageParser The ImageParser instance.

parse(cb)

Prepare the in-memory data (image pixels, buffers, size etc).

Params

  • Function cb: The callback function.

width()

Returns the image width.

Return

  • Number The image width.

height()

Returns the image height.

Return

  • Number The image height.

getPixel(x, y)

Gets the pixel at given coordinates.

Params

  • Number x: The x coordinate.
  • Number y: The y coordinate.

Return

  • Pixel The Pixel instance containing the pixel data.

pixels()

Gets the image pixels.

Return

  • Array An array of Pixel objects containing the pixel information.

resize(width, height, cb)

Resizes the image.

Params

  • Number width: The new image width.
  • Number height: The new image height.
  • Function cb: The callback function.

crop(width, height, x, y, cb)

Crops the image.

Params

  • Number width: The crop width.
  • Number height: The crop height.
  • Number x: The X coordinate.
  • Number y: The Y coordinate.
  • Function cb: The callback function.

save(filePath, cb)

Saves the image to disk.

Params

  • String filePath: The output file path.
  • Function cb: The callback function.

πŸ˜‹ How to contribute

Have an idea? Found a bug? See how to contribute.

πŸ’« Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

  • image-to-asciiβ€”A Node.JS module that converts images to ASCII art.

πŸ“œ License

MIT © Ionică Bizău