上传时默认情况下正在旋转图像

Man*_*uri 10 javascript css jquery samsung-mobile

我正在尝试拍照并使用Samsung S7将其上传到我的应用程序中.但是上传时图像正在旋转.即使我也从图库中选择图像,它也会在上传时旋转.有什么我们可以从jquery代码修复.请建议.提前致谢

HTML:

<div class="photo-div" id="photo">
                <img id="uploadimage" src="" hidden="">
            </div>

<label id="files-label" for="files" class=" myprofile-btn-bold">Replace Image</label>
<input id="files" style="display:none;" type="file" accept="image/*" onchange="readURL(this);">
Run Code Online (Sandbox Code Playgroud)

jQuery的:

function readURL(input) {

    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#files-label').html('Replace Image');
            $('.photo-image').removeClass('photo-image');
            $('#uploadimage').attr('src', e.target.result);
            $("#headshot-message").hide();
            $("#headshot-cancel").hide();
            $('#noimage-label').addClass('hidden');
        }

        reader.readAsDataURL(input.files[0]);
    }
}
Run Code Online (Sandbox Code Playgroud)

Fab*_*her 11

当您转动手机拍照时,当您拿着手机时,指示灯会在方向上照射到相机传感器上.相机应用程序不会保存在屏幕上看到的图像,但它只是使用方向传感器的当前EXIF方向数据标记它们.

此信息由您的图库应用程序解释,以相应地显示图像,但浏览器将忽略它并显示传感器视角拍摄的图片.

转身图片:

您可以根据带有imagemagick自动定位的服务器上的EXIF数据来转动和保存图片:

convert uploadedImage.jpg -auto-orient turnedImage.jpg
Run Code Online (Sandbox Code Playgroud)

或用JavaScript把它们的客户端上的EXIF,东方脚本或使用jQuery在解释这个职位.