1

Specification says

data:[<mime type>][;charset=<charset>][;base64],<encoded data>

Considering this it is easy to split the uri after "," to retrieve the image data. Is there a built in function for the same in javascript or jquery ?

BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
tan
  • 1,554
  • 2
  • 12
  • 34

1 Answers1

4

you could use replace(/^data:image\/(png|jpg);base64,/, '') for example

var encodedData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAB0UlE';

encodedData = encodedData.replace(/^data:image\/(png|jpg);base64,/, '');
Deepak Pandey
  • 608
  • 7
  • 19