@elliotstoner – How did you go with the script offered by @c.pfaffenbichler ?
@c.pfaffenbichler @Stephen Marsh It works! Thank you SO MUCH! I had to make a few small adjustments, and added some comments for clairity - here's what I ended up with:
/*
* Create your base file (this script may be set to expect inchees and 300px/inch for your base file)
* All images should be in .psd format
* Add your images to a subfolder in the same directory as your base file
* Enter the subfolder name from above into the var on line 27 (var subFolder)
* The input should be a .txt file with the following format:
* imageName,xOffset,yOffset (each on a separate line)
* example: Image 1,-3,4.5
*/
if (app.documents.length > 0) {
// Save prefs
var originalRulerUnits = app.preferences.rulerUnits;
// Setup
app.preferences.rulerUnits = Units.PIXELS;
app.runMenuItem(charIDToTypeID("FtOn"));
var theFile = selectFile(false);
var theFiles = readText(theFile);
var myDocument = activeDocument;
var thePath = myDocument.path;
var docWidth = myDocument.width;
var docHeight = myDocument.height;
// The root directory is the location of the base file - put all of your images in a
// subfolder in the same directory as your base file, and put the name of that folder here.
var subFolder = "6in width";
// Place images
var thisOne = theFiles[0];
placeScaleRotateFile(
thePath + "/" + subFolder + "/" + thisOne[0] + ".psd",
docWidth / -2 + thisOne[1] * 300,
docHeight / -2 + thisOne[2] * 300,
100,
100,
0,
false
);
// assumes the images have the same dimensions;
var xOffset = myDocument.activeLayer.bounds[0] * -1;
var yOffset = myDocument.activeLayer.bounds[1] * -1;
myDocument.activeLayer.translate(xOffset, yOffset);
for (var m = 1; m < theFiles.length; m++) {
var thisOne = theFiles[m];
placeScaleRotateFile(
thePath + "/" + subFolder + "/" + thisOne[0] + ".psd",
docWidth / -2 + thisOne[1] * 300 + xOffset,
docHeight / -2 + thisOne[2] * 300 + yOffset,
100,
100,
0,
false
);
}
// Reset prefs
app.preferences.rulerUnits = originalRulerUnits;
}
// ------- Helper Functions -------
// Place File, Scale, and Rotate File
function placeScaleRotateFile(
file,
xOffset,
yOffset,
theXScale,
theYScale,
theAngle,
linked
) {
var idPxl = charIDToTypeID("#Pxl");
var idPrc = charIDToTypeID("#Prc");
var idPlc = charIDToTypeID("Plc ");
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
desc5.putPath(idnull, new File(file));
var idFTcs = charIDToTypeID("FTcs");
var idQCSt = charIDToTypeID("QCSt");
var idQcsa = charIDToTypeID("Qcsa");
desc5.putEnumerated(idFTcs, idQCSt, idQcsa);
var idOfst = charIDToTypeID("Ofst");
var desc6 = new ActionDescriptor();
var idHrzn = charIDToTypeID("Hrzn");
desc6.putUnitDouble(idHrzn, idPxl, xOffset);
var idVrtc = charIDToTypeID("Vrtc");
desc6.putUnitDouble(idVrtc, idPxl, yOffset);
var idOfst = charIDToTypeID("Ofst");
desc5.putObject(idOfst, idOfst, desc6);
var idWdth = charIDToTypeID("Wdth");
desc5.putUnitDouble(idWdth, idPrc, theYScale);
var idHght = charIDToTypeID("Hght");
desc5.putUnitDouble(idHght, idPrc, theXScale);
var idAngl = charIDToTypeID("Angl");
var idAng = charIDToTypeID("#Ang");
desc5.putUnitDouble(idAngl, idAng, theAngle);
if (linked == true) {
var idLnkd = charIDToTypeID("Lnkd");
desc5.putBoolean(idLnkd, true);
}
executeAction(idPlc, desc5, DialogModes.NO);
// get layerid;
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerID"));
ref.putEnumerated(
charIDToTypeID("Lyr "),
charIDToTypeID("Ordn"),
charIDToTypeID("Trgt")
);
var layerDesc = executeActionGet(ref);
var layerID = layerDesc.getInteger(stringIDToTypeID("layerID"));
return [app.activeDocument.activeLayer, layerID];
}
// ------- Read input file ------
function readText(thePath) {
if (File(thePath).exists == true) {
var file = File(thePath);
file.open("r");
file.encoding = "BINARY";
var theText = new String();
for (var m = 0; m < file.length; m++) {
theText = theText.concat(file.readch());
}
var theArray = theText.split("\n");
for (var n = 0; n < theArray.length; n++) {
theArray[n] = theArray[n].split(",");
}
file.close();
return theArray;
}
}
// ------- Select input file ------
function selectFile(multi) {
if (multi == true) {
var theString = "please select files";
} else {
var theString = "please select one file";
}
if ($.os.search(/windows/i) != -1) {
var theFiles = File.openDialog(theString, "*.txt", multi);
} else {
var theFiles = File.openDialog(theString, getFiles, multi);
}
// Filter files for Mac
function getFiles(theFile) {
if (
theFile.name.match(/\.(txt)$/i) ||
theFile.constructor.name == "Folder"
) {
return true;
}
}
return theFiles;
}