简体   繁体   中英

Detect EXIF Orientation of an image in javascript

In my mobile web application, I have a need to examine the EXIF orientation tag of an image file selected using an input type=file control, and this needs to be done on the client side in javascript, before the selected image file gets uploaded to the server.

I have seen several threads similar to this but most of them say to use a library called binaryajax.js to be able to access the EXIF data from the file object. Unfortunately, simply including binaryajax.js in my project causes an Access Denied error in jQuery 1.7.1, and I have no idea why this is happening. This error precludes me from using this jquery library. So I am looking for a solution that does not use this library. Another library I have tried to use is jquery.exif.js and I also get an Access Denied Error Trying to use it.

EDIT:

After much testing, I tracked the cause of the error using binaryajax.js to two links on my home page (which is not the page where I am including the jquery plugin) of the format:

<a onclick="$('#home-form-login').submit();"></a>

Including these click event handlers on the links is causing the access denied error trying to use the plugin. Because the links are on my home page, they are also included in every other page I visit, if that makes sense.

How do I get around this?

I recently ran across this library for image manipulation in JavaScript. It can read EXIF data of an image, including orientation. Worth looking into

https://github.com/blueimp/JavaScript-Load-Image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM