如何从IOS中的NATIVE_URI获取图像元数据

时间:2013-07-26 05:46:25

标签: ios objective-c cordova

我正在IOS中使用getPhoto('Camera.PictureSourceType.PHOTOLIBRARY');开发一个phoneGap应用程序 访问照片库并选择图像。以下是onPhotoURISuccess方法,我需要获取图像的url并将其传递给我的本机插件以验证它的文件大小,分辨率和文件扩展名,稍后我需要将其转换为Hex。

这是我的getPhoto()方法

        // A button will call this function
    function getPhoto(source)
    {            
        // Retrieve image file location from specified source
        navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 100,
                                    destinationType: navigator.camera.DestinationType.NATIVE_URI, sourceType: source });

    }

这是onPhotoURISuccess方法

// Called when a photo is successfully retrieved
function onPhotoURISuccess(imageURI)
{
    img_uri = imageURI;
    console.log('NATIVE_URI==>'+img_uri);

    // Get image handle
    var imgPrev = document.getElementById('imgPreview');

    // Unhide image elements
    imgPrev.style.display = 'block';

    // Show the captured photo
    // The inline CSS rules are used to resize the image
    imgPrev.src = imageURI;

    validateImage(imageURI);
}

根据phoneGap文档,我有三种选择。使用DATA_URL,FILE_URI或NATIVE_URI。 FILE_URI似乎隐藏了图像的基础数据,它总是返回一个peg图像,甚至我也无法获得图像的文件大小。但是NATIVE_URI似乎在其中有一个实例的元数据,我有一个像这样的路径

assets-library://asset/asset.JPG?id=5CF16D20-9A80-483A-AC1C-9692123610B1&ext=JPG

我想知道如何获取图像的元数据,如文件大小和文件扩展名。

0 个答案:

没有答案
相关问题