IOS上传图片翻转问题

使用IOS设备比如IPHONE苹果手机或者平板电脑上传图片时,到后台总是会发现图片又翻转的现象,可以使用Exif.js 读取图像的原始数据的功能扩展,例如:拍照方向、相机设备型号、拍摄时间、ISO 感光度、GPS 地理位置等数据。然后根据拍照方向在客户端调整图片方向就可以了。


乐古 T0 发布于2年前

最佳解决方案

//此处省略HTML
      var Orientation = null;
      var canvasHead = '';
      $('#fileBtn').on('change',function(){
          var files = this.files[0];
          var reader = new FileReader();
          if(typeof FileReader == 'undefined'){
              require('module/common/dialog').showToast('抱歉,您手机暂不支持');
              return;
          }else{
              reader.readAsDataURL(files);
          }
          reader.onloadstart = function(){
              require('module/common/dialog').showLoading('正在读取');
          };
          reader.onabort = function(){
              require('module/common/dialog').hideLoading();
              require('module/common/dialog').showToast('读取中断,请重试');
              return false;
          };
          reader.onerror = function(){
              require('module/common/dialog').hideLoading();
              require('module/common/dialog').showToast('读取发生错误,请重试');
              return false;
          };
          reader.onload = function(){
              require('module/common/dialog').hideLoading();
              require('module/common/dialog').showLoading('读取完成,玩命加载中');
              if(reader.readyState == 2){
                  var fileStr = reader.result;
                  var image = new Image();
                  image.src = fileStr;
                  image.onload = function(){
                      $('#preHead').addClass('preHead');
                      var preHead_canva
                        

乐古 T0 被采纳率67%
2020-11-17 10:53
打赏 0 1
页面统计
1537 访问
0 帮助
0.00 打赏

hierror 2019 © hierror.com 京ICP备13026190号-1

通知消息
  • 暂无任何消息