Giter Club home page Giter Club logo

image-parser's Introduction

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

image-parser's People

Contributors

ionicabizau avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.