Skip to content

Instantly share code, notes, and snippets.

@alanhoff
Last active June 21, 2020 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanhoff/fee5a0b263eef4e6f196 to your computer and use it in GitHub Desktop.
Save alanhoff/fee5a0b263eef4e6f196 to your computer and use it in GitHub Desktop.
Conversor de imagem em base64
var http = require('http');
var path = require('path');
var url = require('url');
// Pegando a imagem na internet
http.get(url.parse(process.argv[2]), function(res){
var img = '';
res.on('data', function(buff){
img += buff.toString('base64');
});
res.on('end', function(){
console.log('<img src="data:image/%s;base64,%s">', process.argv[2].split('.').pop(), img);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment