Search code examples
android-cameratitanium-mobiletitanium-modules

Extract image data from camera roll on Android?


Can anyone help me find out if/how you can get image data off of the 'camera roll' in an Android device, using (Appcelorator) Titanium ? I have found a 3rd party module for IOS that does this but I am desperate to find one for Android. Otherwise I'll have to scrap the Titanium and go true native.

What I need is a function that returns an array of data about the images on the device. Although I would love to get 'geolocation' data ( if it exists ), all I really need is a 'create date', and a path to the image, or the actual TiBlob.
Seems simple but i get no responses on the Appcelerator forums, which worries me. There must be at least an Android 'module' that achieves this?


Solution

  • Ti.Media.openPhotoGallery({
         allowEditing : true,
         success : function(event) {
         var image = require('/modules/parts/squarecropper').crop(event.media);
             setImage(image);
             Ti.Media.hideCamera();
         },
         cancel : function() {
         },
         saveToPhotoGallery : false,
         mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO],
    }); 
    

    The above method would do your job. Now then either access it directly or get into a file system and encode and decode the data.

        var f = Titanium.Filesystem.getFile(currIamge);
        var temp = f.read();
        var encodeData = Ti.Utils.base64encode(temp);
        alert("encodeData = "+encodeData);