
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
A library/stand-alone script to convert images into base64 strings.
npm install img-to-64
var i64 = require('img-to-64');
i64.getImageStrings({
files: ['mike@128px.png', 'mike@256px.png'],
css: true
}, function(err, b64strings) {
if (err) {
throw new Error('oh noeses, somethin is broken!');
}
b64strings.forEach(function(b64) {
console.log(b64);
});
});
###getImageStrings(options, callback)###
The options
object takes a files
key with an Array value of file paths as its value. You can also just use the file
key and pass a String path if you only have a single image to convert. The options
object also takes an optional css
key with a Boolean of whether to output CSS-ready strings of the format "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...".
The callback
function is in the form of function(error, ArrayOfStrings)
If you run from the command line, the script takes two [optional] arguments: a folder and an output file. If an ouput file is not provided, it defaults to base64_images.txt
. If a source dir is not provided, it defaults to .
.
For instance:
./img-to-64 /some/path/to/images base64images.txt
Will output to base64images.txt
data like so:
some_image_1.png : Rw0KGgoAAAANSU....
some_image_2.png : EUgAAAAUA...
FAQs
A library/stand-alone script to convert images into base64 strings
The npm package img-to-64 receives a total of 0 weekly downloads. As such, img-to-64 popularity was classified as not popular.
We found that img-to-64 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.