0

I'm converting the page to canvas and then canvas to the image. Function convertCanvasToImage returns image link as base64 encoded link. Looking for a solution to decode it cause I'll need that later and would be easier.

Encoded image starts with data:image/png;base64,longString.

I tried

var  decodedData = window.atob(n); and http://www.webtoolkit.info/javascript-base64.html

But it returns chinese characters.

Also, I tried sending the encoded string to the server via ajax and then try with base64_decode. Still, I get odd output.

Any reference or solution how to decode base64 png image and get normal URL of the image? Is it possible for a canvas to return normal URL not encoded?

Avinash Singh
  • 4,970
  • 8
  • 20
  • 35
Dejano
  • 119
  • 1
  • 3
  • 9
  • It's an image, what are you expecting when you decode it, english text? When decoded you probably get the binary representation of the image, not an URL! Where would that URL go anyway, did you save the image to disk somewhere? – adeneo Jun 22 '13 at 22:05
  • Aham, then problem is luck of understanding of canvas from me. I tho it's linking image url to img src. Is there a way to build image URL somehow? Edit: No, I didn't. I should save it to server tho. Sending this encoded string to server takes too long (between 10-15 seconds)... – Dejano Jun 22 '13 at 22:07

0 Answers0