Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert base64 to image nodejs

var base64Data = req.rawBody.replace(/^data:image/png;base64,/, "");

require("fs").writeFile("out.png", base64Data, 'base64', function(err) {
  console.log(err);
});
Comment

node.js - How do I convert an image to a base64-encoded data URL

var fs = require('fs');

var imageAsBase64 = fs.readFileSync('./your-image.png', 'base64');
Comment

base64 nodejs image

var fs = require('fs');

// function to encode file data to base64 encoded string
function base64_encode(file) {
    // read binary data
    var bitmap = fs.readFileSync(file);
    // convert binary data to base64 encoded string
    return new Buffer(bitmap).toString('base64');
}
Comment

nodejs read image as base64

const fs = require('fs');
const contents = fs.readFileSync('/path/to/file.jpg', {encoding: 'base64'});
Comment

nodejs read image as base64

const fs = require('fs').promises;
const contents = await fs.readFile('/path/to/file.jpg', {encoding: 'base64'});
Comment

base64 to image nodejs

const fs = require('fs')

// base64 data to buffer
var buffer = Buffer.from('your-base64-data','base64')
// buffer to image
fs.writeFileSync('file-name.jpg',buffer)



Comment

PREVIOUS NEXT
Code Example
Javascript :: unidirectional data flow 
Javascript :: spining load react component 
Javascript :: convert int to timestanp js 
Javascript :: how to give height through props 
Javascript :: reverse javascript 
Javascript :: react router route not found redirect 
Javascript :: remove duplicates in an array in javascript 
Javascript :: adding all elements of an array javascript 
Javascript :: add image to ag-grid with react 
Javascript :: htpp status 
Javascript :: react usecontext 
Javascript :: args slice discord.js 
Javascript :: javascript to number 
Javascript :: axios get image 
Javascript :: javascript textarea autosize 
Javascript :: how to insert an item into an array at a specific index in javascript 
Javascript :: create dynamic element in javascript 
Javascript :: react native image 
Javascript :: react hook form validation 
Javascript :: firebase admin delete user 
Javascript :: creating 2d array in javascript 
Javascript :: Uncaught TypeError: _firebase__WEBPACK_IMPORTED_MODULE_0__.storage.ref is not a function 
Javascript :: ho to loop trough an array of objects 
Javascript :: router in next js 
Javascript :: reverse the string in javascript 
Javascript :: javascript sum of number in object array 
Javascript :: find max and min value in array javascript 
Javascript :: how to get input name in javascript 
Javascript :: javascript max_value 
Javascript :: mongoose db connect 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =