I need to access EXIF
data in images already loaded on page. Say, from browser extension. AFAIU, there are some javascript approaches to accomplish the task:
- use JavaScript-Load-Image;
- use Nihologic EXIF manipulation library;
- draw image on canvas.
First two approaches may either deal with local files or they require to perform an additional (superfluous in this case) request to the server to retrieve binary data. The latter likely works:
var canvas = document.createElement("canvas");
canvas.width = oImg.width;
canvas.height = oImg.height;
// Copy the image contents to the canvas
var ctx = canvas.getContext("2d");
ctx.drawImage(oImg, 0, 0);
// Get the data-URL formatted image
var dataURL = window.atob(canvas.toDataURL("image/jpeg", 1.0).split(',')[1]);
but the resulting binary object does not contain EXIF data (0xE1
marker,) it seems that once drawn on canvas, it yields the JFIF (0xE0
) marker instead.
So, my question is: is it possible to get an access to binary data of already loaded image on the page?
Please note: there are similar questions already on SO, but none answers the question how not to reload an image and get an access to EXIF data.
I understand that I could save an image locally into, say, LocalStorage and then use the library mentioned above but it also looks like an overkill.