PLDaily/blog

图片上传的旋转角度问题

Opened this issue · 0 comments

exif获取旋转角度

使用exif获取图片orientation信息

EXIF.getData(that.file, function (event) {
    var allTags = EXIF.getAllTags(this);
    var orientation = allTags.Orientation;
})

orientation的含义

2017-11-20 9 38 20

2017-11-20 9 38 43

如上俩图所示,我们需要对orientation为3,6,8图片进行矫正
switch (orientation) {
    case 6:
        //需要顺时针(向左)90度旋转
        alert(90)
        break;
    case 8:
        //需要逆时针(向右)90度旋转
        alert(270)
        break;
    case 3:
        //需要180度旋转
        alert(180)
        break;
}

示例

https://github.com/PLDaily/exif

参考