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
  • 700,868
  • 160
  • 1,392
  • 1,356
nithinTa
  • 1,632
  • 2
  • 16
  • 32

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
  • 618
  • 7
  • 19