I have the following task:
<input type=file />
So, I'd like to use JavaScript to extract some EXIF data when a file is added to the input
.
Is this possible?
I know about this question: Can I read Exif data of a picture in the client-side with js? , which refers to http://blog.nihilogic.dk/2008/05/reading-exif-data-with-javascript.html
But my question is (I think?) slightly different - I want to extract the EXIF data before the image is even on my domain, while it's on the user's local filesystem, if you see what I mean. I can access the binary data, so can I get the EXIF too?
Thanks for your advice.
You can do this on the client with HTML5. You should have an appropriate server based fallback for older browsers that don't support File and FileReader.
You can write your own exif parser or use the jsjpegmeta library(Ben Leslie), which is a simple+awesome library that lets the browser extract the EXIF data from most jpeg files. There is a patch that says it fixes most of the compatibility problems. I haven't tested the patch, but be prepared to fork the project and put on your github hat.
To get the EXIF:
<file
input and add a change handler$(this).get(0).files
to get the list of selected files.I had to tweak the library a bit to get it to do what I wanted (I wanted a commonJS library) I also made the tweak identified in issue 1.
Here is a fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With