Search code examples
alignmentphotoshop

Align multiple photos so contents are at same place


I have multiple images like theseenter image description here

enter image description here

and a main photo one with which all others need to agree.

I want in all photos the little squares of the top row to be exactly on the same place(cause I use a Photoshop script to sample the color of each square's center using static coordinates). In many photos the camera moved a little so I need to adjust them (mostly vertically) to fix that. Do you know of any way that this can be done easily on many (cause I have like 1000 of them) photos?
I tried open like 30-40 in Photoshop at a time but need a way to place and keep some reference points. You know any way that this can be done? Maybe guides common for all opened files or something similar?


Solution

  • You can align vertical centres and then distribute the horizontal centres with code:

    function align_tiny_photos()
    { // align and distribute
    var idAlgn = charIDToTypeID( "Algn" );
    var desc48 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var ref16 = new ActionReference();
    var idLyr = charIDToTypeID( "Lyr " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idTrgt = charIDToTypeID( "Trgt" );
    ref16.putEnumerated( idLyr, idOrdn, idTrgt );
    desc48.putReference( idnull, ref16 );
    var idUsng = charIDToTypeID( "Usng" );
    var idADSt = charIDToTypeID( "ADSt" );
    var idAdCV = charIDToTypeID( "AdCV" );
    desc48.putEnumerated( idUsng, idADSt, idAdCV );
    executeAction( idAlgn, desc48, DialogModes.NO );
    
    var idDstr = charIDToTypeID( "Dstr" );
    var desc62 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var ref23 = new ActionReference();
    var idLyr = charIDToTypeID( "Lyr " );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idTrgt = charIDToTypeID( "Trgt" );
    ref23.putEnumerated( idLyr, idOrdn, idTrgt );
    desc62.putReference( idnull, ref23 );
    var idUsng = charIDToTypeID( "Usng" );
    var idADSt = charIDToTypeID( "ADSt" );
    var idAdCH = charIDToTypeID( "AdCH" );
    desc62.putEnumerated( idUsng, idADSt, idAdCH );
    executeAction( idDstr, desc62, DialogModes.NO );
    }
    

    To use:

    align_tiny_photos();