当我们在浏览器使用标签显示图片时,对于iphone手机拍出的照片会存在图片方向和在手机上显示及浏览器直接打开时不同,对于产生这个问题的原因这里有一篇很详细的说明及iOS开发中的处理方式:http://www.tuicool.com/articles/YfeeqaU。在这里,笔者对网页中使用js方式的处理进行简单的记录,便于日后查看。

    1.引入jquery.min.js/jquery.exif.js/jQueryRotate.js

    2.html:

mg id="imgId" src="xxx" exif=true>

    3.js:

var img=$("#imgId");
var orientation=img.exif("Orientation");
if (typeof orientation[0]=='undefined"){
    console.log("没有Orientation信息");
    return;
}
switch (orientation[0]){
    case '3':
        img.rotate(180);
        break;
    case '6':
        img.rotate(90);
        break;
    case '8':
        img.rotate(270);
        break;
}