1.0.2 • Published 3 years ago

node-base64-to-image v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

node-base64-to-image

Convert and save base64 image data to file.

Installation

$ npm i node-base64-to-image --save

Usage

const SaveBase64 = require('node-base64-to-image');
// or
import { SaveBase64 } from 'node-base64-to-image';
app.use((req, res, next) => {
  const base64Data = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJUAAABOCAYAAAApW1S...`;
  const imageNameWithPath = `${__dirname}/public/images/sample-image.jpeg`;
  SaveBase64(base64Data, imageNameWithPath, 'jpeg')
  .then(success => {
    res.send(success);
  }, err => {
    throw err;
  });
});

Parameters

KeyDescription
base64DataToSaveBase64 image data to save into file.
imagePathToSaveWithNameAbsolute path where image need to save with the name of the image to save.
imageExtensionExtension of the Base64 image data.

License

Licensed under MIT. See LICENSE for more information.

Issues

Report a bug in ISSUES.