Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@snailycad/image-data-uri
Advanced tools
Library to easily decode/encode Data URI images
npm install image-data-uri
imageDataURI.decode('data:image/png;base64,SOMEPNGDATAURI/wD/')
// RETURNS
{
imageType: 'image/png',
dataBase64: 'SOMEPNGDATAURI/wD/',
dataBuffer: <Buffer 89 50 4e 47 0d 0a ...>
}
// Expects a Buffer of a image file
let dataBuffer = new Buffer(imageData);
// PNG | GIF | etc.
let mediaType = "PNG";
// RETURNS :: image data URI :: 'data:image/png;base64,PNGDATAURI/wD/'
imageDataURI.encode(dataBuffer, mediaType);
// Returns a Promise
imageDataURI
.encodeFromURL("http://www.some-site.com/some-image.png")
// RETURNS image data URI :: 'data:image/png;base64,PNGDATAURI/'
.then((res) => console.log(res));
// Returns a Promise
imageDataURI
.encodeFromFile("./some-file.png")
// RETURNS image data URI :: 'data:image/png;base64,PNGDATAURI/'
.then((res) => console.log(res));
// Some image data uri
let dataURI = "data:image/png;base64,PNGDATAURI/";
// It will create the full path in case it doesn't exist
// If the extension is defined (e.g. fileName.png), it will be preserved, otherwise the lib will try to guess from the Data URI
let filePath = "./out/path/fileName";
// Returns a Promise
imageDataURI
.outputFile(dataURI, filePath)
// RETURNS image path of the created file 'out/path/fileName.png'
.then((res) => console.log(res));
FAQs
Library to easily decode/encode Data URI images
The npm package @snailycad/image-data-uri receives a total of 55 weekly downloads. As such, @snailycad/image-data-uri popularity was classified as not popular.
We found that @snailycad/image-data-uri 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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.