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

ba64

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ba64

A small npm module for saving base 64 encoded images to your file system.

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
320
increased by42.22%
Maintainers
1
Weekly downloads
 
Created
Source

ba64

Build Status Coverage Status

A tiny npm module for saving Base64 encoded images that are part of data URLs to your file system. This is useful for saving images that have been uploaded to the browser via FileReader.readAsDataUrl().

Installation

npm i ba64 -S

Example

var ba64 = require("ba64"),
	data_url = "data:image/jpeg;base64,[Base64 encoded image goes here]";

// Save the image synchronously.
ba64.writeImageSync("myimage", data_url); // Saves myimage.jpeg.

// Or save the image asynchronously.
ba64.writeImage("myimage", data_url, function(err){
	if (err) throw err;

	console.log("Image saved successfully");

	// do stuff
});

API

# ba64.writeImage(path/to/file_name, data_url, callback)

Asynchronously saves the Base64 encoded image to the file system. file_name should not include the file extension; ba64 will do that for you.

# ba64.writeImageSync(path/to/file_name, data_url)

Synchronously saves the Base64 encoded image to the file system. file_name should not include the file extension; ba64 will do that for you.

Helper functions

# ba64.getExt(data_url)

Returns the file extension of the Base64 encoded image.

# ba64.getBa64Img(data_url)

Returns the Base64 encoded image without the data: scheme prefix.

Keywords

FAQs

Package last updated on 15 Oct 2017

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