Socket
Socket
Sign inDemoInstall

rgba-to-datauri

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rgba-to-datauri

Converts a flat array of RGBA quadruplets or a flattened buffer into a PNG base64 encoded datauri.


Version published
Weekly downloads
2
Maintainers
1
Install size
872 kB
Created
Weekly downloads
 

Readme

Source

rgba-to-datauri

Build Status Coverage Status

Converts either a flat array of RGBA quadruplets (array of 4 integers) or a flattened Buffer ([r,g,b,a,r,g,b,a,...]) into a PNG base64 encoded datauri.

TODO

  • More error handling and input validation.
  • Promisifying (right now convert is sync)

Installation

node.js

Install using npm:

$ npm install rgba-to-datauri

Examples

Node.JS

import {convert} from 'rgba-to-datauri';

const array = [
  [0,0,0,255], [0,0,0,255],
  [0,0,0,255], [0,0,0,255]
];

const buf = new Buffer([0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,255]);

// Should get a png base64 encoded datauri depicting a black 2px by 2px square
const uriFromArray = convert(array, 2, 2);
const uriFromBuffer = convert(buf, 2, 2);

Testing

To run the tests:

$ npm install
$ npm test

Contributing

If you wish to submit a pull request please update and/or create new tests for any changes you make and ensure the tests pass.

License

MIT - see LICENSE

Keywords

FAQs

Last updated on 05 Dec 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc