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++) {
           (function (y) {
               setTimeout(function () {
                   getImageProperties(files[y], y);
               }, 300);

        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 });
        displayNam: file.displayName,
        src: imageBlob,
        path: file.path,
        dateCreated: file.dateCreated,
    return file;

function getImageProperties(file, int) {
        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;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

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
Fabulou wholesale Petr Mrazek jersey is back. Best choice to get the wholesale Petr Mrazek jersey is suitable for all style of people.