How to get array of photos location, size, and camera information Windows 8 JavaScript (WinJS) Example

Windows 8 logoI am taking a break from Android development and getting into Windows 8 apps using Javascript. I am still learning so some of my code will not be best performance but it is tested. This Windows 8 example shows how to take an array of photo files and return an array of photo information including the file properties and image properties using JavaScript. With the image properties you get the meta data of a picture including the location (longitude, latitude), camera model, and image size.  The biggest problem I ran into was looping the array of photos to get the image properties (getImagePropertiesAsync() ). This is because I was not use to asynchronous programming. I found a solution (may not be ideal) online that worked. Not sure how important the timeout is but I know it works. I will have to do more testing to see if I can remove it. I am burnt out at the moment. 

var photoArray = new Array();
function decodePicture(files) {
    if (files.length > 0) {
        var index = 0;
        for (var y = 0; y < files.length; y++) {
            getFileProperties(files[y],y);
           (function (y) {
               setTimeout(function () {
                   getImageProperties(files[y], y);
               }, 300);
           })(y);

        }
        return photoArray;
    } else {
        // The picker was dismissed with no selected file
        WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
        return null;
    }
}

function getFileProperties(file, updateStorage) {
    var imageBlob = URL.createObjectURL(file, { oneTimeOnly: true });
    photoArray.push({
        displayNam: file.displayName,
        name: file.name,
        src: imageBlob,
        path: file.path,
        dateCreated: file.dateCreated,
    });
    return file;
}

function getImageProperties(file, int) {
    file.properties.getImagePropertiesAsync().then(
        function (imageProperties) {
            if (imageProperties.longitude != null) {
                Data.photoArray[int].longitude = imageProperties.longitude;
                Data.photoArray[int].latitude = imageProperties.latitude;
            }
            else {
                Data.photoArray[int].longitude = null;
                Data.photoArray[int].latitude = null;
            }
            Data.photoArray[int].make = imageProperties.cameraManufacturer;
            Data.photoArray[int].model = imageProperties.cameraModel;
        }, function onReject(err) { console.log('NOT OK', err.stack) })
        .done(function () {
            return true;
        });
}

Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on

  • wholesale nfl jerseys
  • wholesale nfl jerseys china
  • wholesale sports jerseys