I have a Highcharts chart that I've converted from canvas to Base64 using the following javascript in my Rails 3.2 app.
canvg(document.getElementById('chart'), chart.getSVG())
var canvas = document.getElementById("chart");
var img = canvas.toDataURL("image/png");
document.write('<img src="'+img+'"/>');
Now, I want to decode that image into an image file. However, I do not want to save it to the server because the sole purpose is to share on Facebook. I see two options:
-Send data from img
back to the server and then convert that into an image stored in a temp folder, and render in view.
-Use javascript to decode the Base64 to a PNG file and open it in a new window.
Which direction should I take and how would I implement it? I've googled for hours and found a few examples that did parts of what I need, but I can't find the whole story.
This solution seemed very promising, but my image is too big to use a get request and I'm not very familiar with javascript so my attempts to use a post request failed:
Convert canvas to image and open in new window using ruby on rails and javascript
EDIT: As another potential solution, is there a web tool where I can send the base64 string that will automatically return a link with the image?