【问题标题】:PhoneGap iOS - Camera resizing only if photo bigger then targetheight / targetwidthPhoneGap iOS - 仅当照片大于目标高度/目标宽度时才调整相机大小
【发布时间】:2012-10-17 13:33:28
【问题描述】:

我正在使用带有内置相机插件的 Cordova 2.0。我的应用程序包含大量上传到远程服务器的照片,出于带宽和性能原因,我必须限制手机端文件的大小。

我正在使用以下相机选项拍摄新照片:

    var options = {
        quality : 30,
        destinationType : navigator.camera.DestinationType.FILE_URI,
        targetWidth: 1600,
        targetHeight: 1200
    }

这非常适合手机拍摄的照片,因为它们通常大于 1600x1200。但是,当我上传现有照片时,我不想放大小于目标分辨率的图像:

    var options = {
        quality : 30,
        sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY,
        destinationType : navigator.camera.DestinationType.FILE_URI,
        targetWidth: 1600,
        targetHeight: 1200
    };

实际上,我总是想避免扩大规模。关于如何更改相机插件的“缩放模式”的任何想法?

【问题讨论】:

    标签: ios cordova image-uploading cordova-2.0.0


    【解决方案1】:

    根据文档http://docs.phonegap.com/en/2.2.0/cordova_camera_camera.md.html#camera.getPicture,无论图像质量如何,照片库中的图像都无法缩放。仅当从手机中取出时。

    【讨论】:

    • 实际上只是他们所指的质量没有被缩放。照片库中的图像将根据 targetHeight 和 targetWidth 缩小/放大。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-18
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 2013-04-28
    • 2015-03-03
    相关资源
    最近更新 更多