1

我正在 IOS 中开发一个 phoneGap 应用程序, getPhoto('Camera.PictureSourceType.PHOTOLIBRARY'); 用于访问照片库并选择图像。以下是 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

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

4

0 回答 0