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
});
Aside from this, I cannot seem to find a helpful tutorial or question on how to accomplish something similar. Like I said, this is the only package that seems to work with this sort of input so if there is one of use please let me know. Otherwise, Any help will be greatly appreciated.