Search code examples
javascriptlocal-storageexifdata-url

EXIF removed when image is converted to DataURL for local storage?


Is EXIF metadata removed/deleted when an image is converted to DataURL form so it can be stored in a browsers local storage? Specifically Chrome if it makes a difference.


Solution

  • When you convert any image to a data URL, you're just base64 encoding the binary stream of the image file. So, in short, no.

    Edit: If you are specifically drawing an image to an HTML5 Canvas and then converting its data to a data URL with its toDataUrl method, of course EXIF data of the original image would be removed, because a Canvas instance doesn't use anything but the pixel data it contains and its pixel dimensions to generate that data url (if it uses anything else its isn't obvious to me). Any data URL generated wouldn't even necessarily look like one generated from the original file as as the files could be compressed differently, even when generating lossless PNGs.