Utils for base64 image data.
JavaScript
Latest commit 24deef9 Aug 29, 2016 @javierbyte Version bump 0.2.0
Permalink
Failed to load latest commit information.
lib Version bump 0.2.0 Aug 29, 2016
.gitignore Initial commit Mar 23, 2016
CHANGELOG.md Version bump 0.2.0 Aug 29, 2016
README.md Version bump 0.2.0 Aug 29, 2016
index.js Add base64ImageToRGBArray method Mar 23, 2016
package.json Version bump 0.2.0 Aug 29, 2016

README.md

base64 image utils

Utils for base64 image data.

Installation

  npm i base64-image-utils --save

Usage

  var base64ImageUtils = require('base64-image-utils')

  var {base64ImageToRGBMatrix, base64ImageToRGBArray} = base64ImageUtils

  base64ImageToRGBMatrix(base64Image, function(err, data) {
    /*
      data is a matrix with rows and columns that corresponds
      to every pixel of the image, where each pixel is represented
      as:
        {
          r: <Red value of the color>,
          g: <Green value of the color>,
          b: <Blue value of the color>,
          a: <Alpha value of the color>
        }
    */
  })

  base64ImageToRGBArray(base64Image, function(err, data) {
    /*
      data is an array with every pixel described as:
      as:
        {
          x: <X position of the pixel>,
          y: <Y position of the pixel>,
          rgb: {
            r: <Red value of the color>,
            g: <Green value of the color>,
            b: <Blue value of the color>,
            a: <Alpha value of the color>
          }
        }
    */
  })

You can optionally send a third options parameter, which is an object that can hold width or maxWidth values.