I am not sure why you have that scenario required but you can achieve it using below steps.
I am considering you have SVG available.
You can considering converting SVG to Binary (Image) and save that blob into database.
var html = d3.select("svg")
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node().parentNode.innerHTML;
In above code you will get html as string of binary values which represents that Image.
Now you can convert this Binary String to Binary Array or you can store it as it is in database.
If you are achieving just to save Image on server, then I would suggest that generate an Image and save on server with unique GUID Name and save that information in database.
Thanks
Rushi