图像上传然后自动图像在预览图像标签中旋转?
问题描述:
我上传的图像在文件上传控制的变化事件,然后图像自动旋转看到预览标记在我的asp.net mvc c#但我上传现有的图像上传它是好的,但我点击iPhone中的图像,然后图像上传时间图像旋转。以下代码用于预览图像。图像上传然后自动图像在预览图像标签中旋转?
这是我的文件上传控制
<img id="PreviewImage" class="mb20" width="300" src="../@Url.Content(@Url.Content(Model.ProfileImage))" />
@Html.TextBoxFor(model => model.UserFileUpload, new { type = "file", onchange = "ShowVehicleImagePreview(this)" })
这是我的功能
function ShowVehicleImagePreview(input) {
if (input.files && input.files[0]) {
var readervehicle = new FileReader();
readervehicle.onload = function (e) {
$('#PreviewImage').prop('src', e.target.result).width(300);
};
readervehicle.readAsDataURL(input.files[0]);
}
}
任何一个有关于这个问题的想法?
答
也许图像文件,它有自己的元数据orientation
和iPhone展示给你的正确旋转,因为它的校正图像,也许这回答可以帮助:
How to rotate JPEG images based on the orientation metadata?