Home > Backend Development > PHP Tutorial > javascript - LocalResizeIMG.js在iphone下上传图片旋转了90度,如何解决

javascript - LocalResizeIMG.js在iphone下上传图片旋转了90度,如何解决

WBOY
Release: 2016-06-06 20:07:10
Original
1485 people have browsed it

LocalResizeIMG.js在iphone下上传图片旋转了90度,如何解决

回复内容:

LocalResizeIMG.js在iphone下上传图片旋转了90度,如何解决

这个要在这个js源码里去做图片旋转处理

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

        // 执行前函数
        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));
    }</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template