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

node fetch image to base64

import fetch from 'node-fetch'
const res = await fetch(image)

const imgBody = `data:${res.headers.get('content-type')};base64,${(await res.arrayBuffer()).toString('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 :: react JSON data to display in a table 
Javascript :: how to draw a horizontal line in javascript 
Javascript :: react native toast message 
Javascript :: reverse the string in javascript 
Javascript :: send json body http get flutter 
Javascript :: lodash swap array elements 
Javascript :: convert jquery to string 
Javascript :: react native password meter 
Javascript :: regex.match 
Javascript :: add two numbers in jquery 
Javascript :: react onclick runs on load 
Javascript :: javascript play audio from buffer 
Javascript :: array javascript django 
Javascript :: js check if string is int 
Javascript :: update to node 12 mac 
Javascript :: how to get the current time of a audio in js 
Javascript :: define a class in javascript 
Javascript :: how to add to an array js 
Javascript :: react big calendar event color 
Javascript :: how to use platform.select 
Javascript :: cypress multiple true 
Javascript :: for of loop 
Javascript :: javascript onclick append a new row to table 
Javascript :: google recaptcha reload 
Javascript :: javascript regex stop at first match 
Javascript :: cypress graphql request 
Javascript :: json_decode javascript 
Javascript :: get param is react 
Javascript :: identify primary colors in img with js 
Javascript :: trigger a function inside child from parent vue 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =