I have a base64 encoded image returned from a service and it looks like this:
/9j/4AAQSkZJRgABAQEASABIAAD/4Yp2aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWN
Was just tweaking with the string. May be this could help.
base64Data.substring("data:image/".length, base64Data.indexOf(";base64"))