crisconru / image-reader-helper

Image Reader Helper Lib Writted in TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image Read Helper

Test npm

This library allows you to get some information about images; reading and getting information like width, height and the palette colour.

Instalation

To install this library, use npm install.

npm install image-reader-helper

This library is created with TypeScript and compiled for ES6. Here is an example of use:

You can read a file using his path.

import {ImageReader,ImageModel} from 'image-reader-helper';

let model:ImageModel=ImageReader.read('path to your file'); 

Or using a Buffer:

let buffer = fs.readFileSync('path to your file');

let model:ImageModel=ImageReader.read(buffer);

The ImageModel class have this Properties:

  • width: Image Width in pixels.
  • height: Image Height in pixels.
  • plaette: Array of ImageColor with all the disctint colours of the image.(Palette Color).
  • data: Array with all the pixels of the image. each pixel is 4 bytes in the array [r,g,b,a,r,g,b,a...].

The Image Color class have this properties:

  • r: Red value (0-255).
  • g: Green value (0-255).
  • b: Blue value (0-255).
  • a: Alpha value (0-255).

About

Image Reader Helper Lib Writted in TypeScript

License:MIT License


Languages

Language:TypeScript 100.0%