Hello,
There may be easier ways to achieve this, but this is the method I use.
property document_resolution : 300
on run
display dialog "Please drop some images on the icon to run"
end run
on open (addedItems)
set masterList to {}
set overallWidth to 0
set overallHeight to 0
repeat with thisPath in addedItems
set end of masterList to thisPath as text
set PixelWidth to paragraph 2 of (do shell script "sips --getProperty pixelWidth " & (quoted form of POSIX path of thisPath) & " | awk '/.*/ {print $2}' ") as integer
set PixelHeight to paragraph 2 of (do shell script "sips --getProperty pixelHeight " & (quoted form of POSIX path of thisPath) & " | awk '/.*/ {print $2}' ") as integer
if overallHeight is less than PixelHeight then set overallHeight to PixelHeight
set overallWidth to overallWidth + PixelWidth
end repeat
set countImages to (count masterList)
if countImages is less than 2 then
display dialog "Not enough images to create lineup" buttons {"OK"} default button 1 with icon note
return
end if
tell application "Adobe Photoshop CS6"
activate
set Newdoc to make new document with properties ¬
{name:("Image_Lineup"), resolution:document_resolution, width:overallWidth as pixels, height:overallHeight as pixels, mode:RGB}
set current document to Newdoc
repeat with i from 1 to (count masterList)
my openDupeAlign((item i of masterList), i, Newdoc)
end repeat
set alllayerlist to every art layer of current document
my Select_Layers(Newdoc, ("Background"), "addToSelection")
my alignToEdge("Rg")
my Select_Layers(Newdoc, ("Background"), "removeFromSelection")
my Select_Layers(Newdoc, ("Background"), "addToSelectionContinuous")
my Select_Layers(Newdoc, ("Background"), "removeFromSelection")
if countImages is greater than 2 then
do javascript "var idDstr = charIDToTypeID( 'Dstr' );
var desc76 = new ActionDescriptor();
var idnull = charIDToTypeID( 'null' );
var ref39 = new ActionReference();
var idLyr = charIDToTypeID( 'Lyr ' );
var idOrdn = charIDToTypeID( 'Ordn' );
var idTrgt = charIDToTypeID( 'Trgt' );
ref39.putEnumerated( idLyr, idOrdn, idTrgt );
desc76.putReference( idnull, ref39 );
var idUsng = charIDToTypeID( 'Usng' );
var idADSt = charIDToTypeID( 'ADSt' );
var idAdCH = charIDToTypeID( 'AdCH' );
desc76.putEnumerated( idUsng, idADSt, idAdCH );
executeAction( idDstr, desc76, DialogModes.NO );"
end if
my Select_Layers(Newdoc, ("Background"), "addToSelectionContinuous")
my alignToEdge("CV")
end tell
end open
on Select_Layers(Doc_Ref, Layer_Ref, Add_Ref)
-- Add_Ref = addToSelection, addToSelectionContinuous or removeFromSelection
tell application "Adobe Photoshop CS6"
tell Doc_Ref
do javascript "Select_Layers(); function Select_Layers() { function cTID(s) { return app.charIDToTypeID(s); }; function sTID(s) { return app.stringIDToTypeID(s); }; var desc01 = new ActionDescriptor(); var ref01 = new ActionReference(); ref01.putName( cTID('Lyr '), '" & Layer_Ref & "' ); desc01.putReference( cTID('null'), ref01 ); desc01.putEnumerated( sTID('selectionModifier'), sTID('selectionModifierType'), sTID('" & Add_Ref & "') ); desc01.putBoolean( cTID('MkVs'), false ); executeAction( cTID('slct'), desc01, DialogModes.NO );};"
end tell
end tell
end Select_Layers
on openDupeAlign(openFile, layerName, targetDoc)
tell application "Adobe Photoshop CS6"
open file openFile
set name of layer 1 of current document to layerName
duplicate layer 1 of current document to beginning of targetDoc
close current document without saving
end tell
end openDupeAlign
on alignToEdge(edgeToAlign)
tell application "Adobe Photoshop CS6"
do javascript "var idAlgn = charIDToTypeID( 'Algn' );
var desc36 = new ActionDescriptor();
var idnull = charIDToTypeID( 'null' );
var ref30 = new ActionReference();
var idLyr = charIDToTypeID( 'Lyr ' );
var idOrdn = charIDToTypeID( 'Ordn' );
var idTrgt = charIDToTypeID( 'Trgt' );
ref30.putEnumerated( idLyr, idOrdn, idTrgt );
desc36.putReference( idnull, ref30 );
var idUsng = charIDToTypeID( 'Usng' );
var idADSt = charIDToTypeID( 'ADSt' );
var idAd" & edgeToAlign & " = charIDToTypeID( 'Ad" & edgeToAlign & "' );
desc36.putEnumerated( idUsng, idADSt, idAd" & edgeToAlign & " );
executeAction( idAlgn, desc36, DialogModes.NO );"
end tell
end alignToEdge
Save it as a droplet and drop jpegs onto it. If the sizes of the images differ too much the distribution of images will be a bit odd.
Set your preferred resolution in the property at the top of the script
It will set your document to the combined width of the images and the maximum height, based on image data it gets from image events.
Ian