通过PhoneGap(iOS)上传后,图像侧向翻转/上下颠倒 [英] Images turning sideways/upside down after being uploaded via PhoneGap (iOS)

查看:217
本文介绍了通过PhoneGap(iOS)上传后,图像侧向翻转/上下颠倒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定会导致什么,但是当我通过 FileTransfer() ,图片有时会显示为横向或倒置。但是,当我在iPhone上本地查看图像时,它们以正确的方式放置。

Not sure what would be causing this, but when I upload some images to my remote server via FileTransfer(), the images sometimes show up either sideways or upside down. However, when I view the images locally on the iPhone, they are positioned in the correct way.

例如,当我选择要上传的图像时: http://sharefa.st/view/WBe2QNSK8r8z

For example, when I select an image like this to upload: http://sharefa.st/view/WBe2QNSK8r8z

像这样: http://sharefa.st/view/EWdW1Z4G8r8z

我使用本地路径传输文件,所以我不明白为什么图片会随机旋转。

I am using the local path to transfer the file, so I don't understand why the image would rotate "randomly".

这是我的上传功能: p>

Here is my upload function:

function uploadPhoto() {

    var options = new FileUploadOptions();
    options.fileKey  = 'file';
    options.fileName = imgURI.substr(imgURI.lastIndexOf('/')+1);
    options.mimeType = 'image/jpeg';

    var params = new Object();

    if(logged_in == true) {

        params.unique_id  = app_unique_id; 
        params.secret_key = user_secret_key;

    }

    options.params = params;

    loadingStart();

    var ft = new FileTransfer();

    ft.upload(imgURI, 'http://' + remote_server + '/API/upload', uploadDetails, fail, options);

}

imgURI value如下所示:

imgURI value looks like this:

file://localhost/var/mobile/Applications/<snip>/tmp/photo_015.jpg

任何洞察力是值得赞赏的。

Any insight is appreciated.

推荐答案

感谢人类主义指出,问题实际上是与iPhone,以及它存储图像的方式,我能够找出一个解决方案。

Thanks to Humanoidism pointing out that the issue was in fact with the iPhone, and the way it stored images, I was able to figure out a solutuion.

要以正确的方向上传照片,必须将 correctOrientation 设置添加到 getPicture(),并将其设置为 true

To upload photos in the correct orientation you must add the correctOrientation setting to the options array in getPicture(), and set it to true.

以下是两个示例:

function capturePhoto() {

    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 30, correctOrientation: true });

}

function getPhoto(source) {

    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 30, 
    destinationType: destinationType.FILE_URI,
    sourceType: source,
    correctOrientation: true });

}

这篇关于通过PhoneGap(iOS)上传后,图像侧向翻转/上下颠倒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆