1024programmer Java javascript-LocalResizeIMG.js rotates 90 degrees when uploading images on iPhone, how to solve it

javascript-LocalResizeIMG.js rotates 90 degrees when uploading images on iPhone, how to solve it

LocalResizeIMG.js rotates 90 degrees when uploading images on iPhone, how to solve it

Reply content:

LocalResizeIMG.js rotates 90 degrees when uploading images on iPhone, how to solve it

This requires image rotation processing in this js source code

 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;
                 }
             });
         }

         // function before execution
         if($.isFunction(obj.before)) { obj.before(this, blob, file) };

         _create(blob, file);
         this.value = ''; // Clear temporary data

     });

     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));
     }

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/javascript-localresizeimg-js-rotates-90-degrees-when-uploading-images-on-iphone-how-to-solve-it-2/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索