Skip to main content
Known Participant
July 24, 2015
Answered

Stack images shot within 10 seconds of each other in Bridge (like lightroom)

  • July 24, 2015
  • 1 reply
  • 1876 views

I shoot about 1000 pictures a day and Bridge takes 10-15 minutes to analyze and put them into stacks (and even then, it misses some).

Is it possible to write a script that just stacked every image shot within 10 seconds of each other (or some other arbitrary time period).

thanks

This topic has been closed for replies.
Correct answer I have gone

Please give this a try, it should be within 10 seconds.

To use: Stacks - Ten Second Stack

(Might take a bit longer than 10 seconds )

#target bridge;

   if( BridgeTalk.appName == "bridge" ) { 

tenStack = MenuElement.create("command", "Ten Second Stack", "at the end of submenu/Stack");

}

tenStack.onSelect = function () {

//Change to suit

///////////////////////////////////

var Secs = 10; ///

//////////////////////////////////

Secs = Secs * 1000;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var folder1 = Folder(app.document.presentationPath);

var fileList = folder1.getFiles(/\.(jpg|jpe|jpeg|gif|eps|dng|bmp|tif|tiff|psd|crw|cr2|rle|dib|cin|dpx|ps|pcd|pict|vda|icb|vst|wbm|sct|pbm|flm|psb|exr|pcx|pdp|nef|dcr|dc2|erf|raf|orf|tga|mrw|mos|srf|pic|pct|pxr|pdd|pef|png|x3f|raw|rw2)$/i);

var fileArray = new Array();

for(var a in fileList){

var md = new Thumbnail(fileList).synchronousMetadata;

md.namespace = "http://ns.adobe.com/xap/1.0/";      

var dateTime = new XMPDateTime(new Thumbnail(fileList).metadata.read("http://ns.adobe.com/exif/1.0/","DateTimeOriginal")).getDate().getTime();

fileArray.push([[decodeURI(fileList.name)],[dateTime]]);

}

fileArray = fileArray.sort(function(a,b){return a[1]-b[1];});

while( fileArray.length > 2){

    count=0;

    tmpArray=[];

    tmpArray.push(fileArray.shift());

    cmp = Number(tmpArray[0][1]) + Secs;

count = getCount(cmp);

for(var y =0;y <count;y++){

    tmpArray.push(fileArray.shift());

    }

    if(count > 0) {

        app.document.deselectAll();

        for(var s in tmpArray){

            var splitIt=tmpArray.toString().split(',');

        app.document.select(new Thumbnail(new File(app.document.presentationPath + "/" + splitIt[0])));

        }

    app.document.chooseMenuItem("StackGroup");

        }

}

function getCount(){

count=0;

    for(var g = 0;g<fileArray.length;g++){

        if(Number(fileArray[1]) <= cmp){

            count++;

            }else{break;}

        }

    return count;

};

};

I have goneCorrect answer
Inspiring
July 25, 2015

Please give this a try, it should be within 10 seconds.

To use: Stacks - Ten Second Stack

(Might take a bit longer than 10 seconds )

#target bridge;

   if( BridgeTalk.appName == "bridge" ) { 

tenStack = MenuElement.create("command", "Ten Second Stack", "at the end of submenu/Stack");

}

tenStack.onSelect = function () {

//Change to suit

///////////////////////////////////

var Secs = 10; ///

//////////////////////////////////

Secs = Secs * 1000;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var folder1 = Folder(app.document.presentationPath);

var fileList = folder1.getFiles(/\.(jpg|jpe|jpeg|gif|eps|dng|bmp|tif|tiff|psd|crw|cr2|rle|dib|cin|dpx|ps|pcd|pict|vda|icb|vst|wbm|sct|pbm|flm|psb|exr|pcx|pdp|nef|dcr|dc2|erf|raf|orf|tga|mrw|mos|srf|pic|pct|pxr|pdd|pef|png|x3f|raw|rw2)$/i);

var fileArray = new Array();

for(var a in fileList){

var md = new Thumbnail(fileList).synchronousMetadata;

md.namespace = "http://ns.adobe.com/xap/1.0/";      

var dateTime = new XMPDateTime(new Thumbnail(fileList).metadata.read("http://ns.adobe.com/exif/1.0/","DateTimeOriginal")).getDate().getTime();

fileArray.push([[decodeURI(fileList.name)],[dateTime]]);

}

fileArray = fileArray.sort(function(a,b){return a[1]-b[1];});

while( fileArray.length > 2){

    count=0;

    tmpArray=[];

    tmpArray.push(fileArray.shift());

    cmp = Number(tmpArray[0][1]) + Secs;

count = getCount(cmp);

for(var y =0;y <count;y++){

    tmpArray.push(fileArray.shift());

    }

    if(count > 0) {

        app.document.deselectAll();

        for(var s in tmpArray){

            var splitIt=tmpArray.toString().split(',');

        app.document.select(new Thumbnail(new File(app.document.presentationPath + "/" + splitIt[0])));

        }

    app.document.chooseMenuItem("StackGroup");

        }

}

function getCount(){

count=0;

    for(var g = 0;g<fileArray.length;g++){

        if(Number(fileArray[1]) <= cmp){

            count++;

            }else{break;}

        }

    return count;

};

};

cutch2222Author
Known Participant
July 25, 2015

Fantastic as usual, Phillip!

Not as fast as lightroom - but it does do the trick. It took 5 minutes on 500 pics. 11 minutes on 800.

It also behaves differently than lightroom in that it stacks all images taken in the 10 second window of the initial photo (which is what I wanted) Lightroom will stack anything taken within 10- seconds of the last photo in the stack, often resulting in the stacking of 2 unrelated photos.

thank you so much.