I have different types of image content in base64 format in javascript, like:
a png file: "iVBORw0KGgoAAAANSUhEUgAABQAAAAL4CAYAAAAkgloNAAAgA......."
a jpeg file: "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDA......"
similarly, there can be other images like GIF, BMP, etc.
I need a way to determine the image type based on the content. I understand there are headers for each file type and I can refer it to determine the image content type. Example Reference: http://en.wikipedia.org/wiki/Portable_Network_Graphics#Technical_details.
But does anyone know of a library or other technique that will do the trick in a more smarter way? I can use any of the HTML5 features if required.
The main intent is to render the image on the screen. For that I use dataURI pattern, . I have image content, all I need is to put the right value in the "data:image/png" part of the url.