Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

base64-img

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base64-img

Convert img or svg to base64, or convert base64 to img

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24K
increased by1.39%
Maintainers
1
Weekly downloads
 
Created
Source

base64-img

Convert img to base64, or convert base64 to img

var base64Img = require('base64-img');

install

npm install base64-img --save

test

mocha

API

.base64(filename, callback)

Convert image file to image base64 data

  • {string} filename required
    The image path
  • {function} callback(err, data) required
    Callback with image base64 data
base64Img.base64('path/demo.png', function(err, data) {})

.base64Sync(filename)

The api same as base64, but it's synchronous

var data = base64Img.base64Sync('path/demo.png');
var data2 = base64Img.base64Sync('path/demo.svg');

.requestBase64(url, callback)

  • {string} url required
  • {function} callback(err, res, body) required
    Callback with http request
var url = 'http://../demo.png';
base64Img.requestBase64(url, function(err, res, body) {
  
});

.img(data, destpath, name, callback)

Convert image base64 data to image

  • {string} data required
    Image base64 data
  • {string} destpath required
    Dest path, if the destpath is root, pass empty string
  • {string} name required
    The image's filename
  • {function} callback(err, filepath) required
base64Img.img('data:image/png;base64,...', 'dest', '1', function(err, filepath) {});

.imgSync(data, destpath, name)

The api same as img, but it's synchronous

var filepath = base64Img.imgSync('data:image/png;base64,...', '', '2');

Keywords

FAQs

Package last updated on 13 Feb 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc