LocalResizeIMG.js在iphone下上傳圖片旋轉了90度,如何解決
回複內容:
LocalResizeIMG.js在iphone下上傳圖片旋轉了90度,如何解決
這個要在這個js
源碼裡去做圖片旋轉處理
var angle = ''; this.on('change', function () { var file = this.files[0]; var URL = window.URL || webkitURL; var blob = URL.createObjectURL(file); var BinaryAjax = window.BinaryAjax || '', EXIF = window.EXIF || ''; if (BinaryAjax && EXIF) { // get photo orientation and set angle BinaryAjax(blob, function(o) { var oExif = EXIF.readFromBinaryFile(o.binaryResponse), orientation = oExif.Orientation; switch(orientation) { case 6: angle = radians('90deg'); break; case 3: angle = radians('180deg'); break; case 8: angle = radians('270deg'); break; } }); } // 執行前函數 if($.isFunction(obj.before)) { obj.before(this, blob, file) }; _create(blob, file); this.value = ''; // 清空臨時資料 }); function radians(angle) { if (typeof angle == 'number') return angle; return { rad: function(z) { return z; }, deg: function(z) { return Math.PI / 180 * z; } }[String(angle).match(/[a-z]+$/)[0] || 'rad'](parseFloat(angle)); }