Last active
June 21, 2020 19:57
-
-
Save alanhoff/fee5a0b263eef4e6f196 to your computer and use it in GitHub Desktop.
Conversor de imagem em base64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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