I have been looking for a JavaScript solution to converting an image from an external url to a data uri. I have installed multiple packages and tested multiple methods but have not been able to find a usable method for doing so.
What I want:
var url = 'https://static-00.iconduck.com/assets.00/npm-icon-512x512-qtfdrf37.png';
var output = convertToUri(`${url}`); // doesn't need to be a one liner just anything relatively simple that works
res.send(`${output}`);
The closest thing I have: (using data-uri package from npm)
var url = 'https://static-00.iconduck.com/assets.00/npm-icon-512x512-qtfdrf37.png';
data_uri.encode(=`${url}`, function(results){
console.log(results); // this comes in json form that doesn't seem to want to cooperate with JSON.parse();
// if somebody could figure this out that would be equally as helpful
// https://www.npmjs.com/package/data-uri
});
I have found a way to do this using
image-to-base64package: