buffer-to-data-url
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

buffer-to-data-url

License Sponsor buffer-to-data-url
Build status Commits since v1.0.0 Last commit Issues
Latest version on npm Dependents Downloads

Creates a base64-encoded data URL from a Buffer and a mimetype.

Installation

buffer-to-data-url on npm

npm install --save buffer-to-data-url@^1.0.0

buffer-to-data-url on Yarn

yarn add buffer-to-data-url@^1.0.0

@jaid/buffer-to-data-url on GitHub Packages
(if configured properly)

npm install --save @jaid/buffer-to-data-url@^1.0.0

Example

import bufferToDataUrl from "buffer-to-data-url"
 
const imageBuffer = fs.readFileSync("pikachu_8x8.png")
const dataUrl = bufferToDataUrl("image/png", imageBuffer)

Variable result will be:

"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAARklEQVQoU2P8/Z/hPwMewEiUAhaG/wyMjIwMv6FmIfPBJrAyQuyAKUDmo1iBrhCkifG/oBrY4D/vbqE4lUVIDcwnrICQLwAWoihJ/lJMVwAAAABJRU5ErkJgggAA"

Development

Setting up:

git clone git@github.com:jaid/buffer-to-data-url.git
cd buffer-to-data-url
npm install

Testing:

npm run test:dev

Testing in production environment:

npm run test

License

MIT License
Copyright © 2020, Jaid <jaid.jsx@gmail.com> (https://github.com/jaid)

/buffer-to-data-url/

    Package Sidebar

    Install

    npm i buffer-to-data-url

    Weekly Downloads

    631

    Version

    1.0.0

    License

    none

    Unpacked Size

    6.89 kB

    Total Files

    5

    Last publish

    Collaborators

    • jaid