SkillAgentSearch skills...

Ba64

A tiny npm module for saving Base64 encoded images that are part of data URLs to your file system.

Install / Use

/learn @HarryStevens/Ba64
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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().

<a name="installation" href="#installation">Installation</a>

npm i ba64 -S

<a name="example" href="#example">Example</a>

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
});

<a name="api" href="#api">API</a>

<a name="writeImage" href="#writeImage">#</a> 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.

<a name="writeImageSync" href="#writeImageSync">#</a> 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

<a name="getExt" href="#getExt">#</a> ba64.getExt(data_url)

Returns the file extension of the Base64 encoded image.

<a name="getBa64Img" href="#getBa64Img">#</a> ba64.getBa64Img(data_url)

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

Related Skills

View on GitHub
GitHub Stars10
CategoryDevelopment
Updated5y ago
Forks1

Languages

JavaScript

Security Score

75/100

Audited on Nov 15, 2020

No findings