I saved the files as a .PSJS files and tried to open the script in PhotoShop but it doesn't seem to do anything when Opened.
By @Lucky_me
This is a legacy ExtendScript .JSX file, not a new UXP Script .PSJS file.
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
NOTE: When Adobe changed the forum software, many old scripts were broken if they contained a variable in square brackets, such as [i] or [a] etc.
/*
Automate focus stacking.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/automate-focus-stacking-script-action-help-needed/m-p/12742549#M622233
SuperMerlin, Jun 07, 2019
*/
#target photoshop;
app.bringToFront();
main();
function main() {
var selectedFolder = Folder.selectDialog("Please select the folder to process");
if (selectedFolder == null) return;
var outFolder = Folder(selectedFolder + "/processed");
if (!outFolder.exists) outFolder.create();
var threeFiles = new Array();
var PictureFiles = selectedFolder.getFiles(/\.(jpg|jpe|dng|bmp|tif|tiff|psd|crw|cr2|exr|pcx|nef|dcr|dc2|erf|raf|orf|tga|mos|pef|png)$/i);
while (PictureFiles.length > 2) {
for (var a = 0; a < 3; a++) {
threeFiles.push(PictureFiles.shift());
}
stackFiles(threeFiles);
selectAllLayers();
autoAlign();
autoBlendLayers();
var layerName = activeDocument.activeLayer.name.replace(/\....$/i, '');
var saveFile = new File(outFolder + '/' + layerName + '.psd');
SaveTIFF(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
threeFiles = [];
}
};
function autoBlendLayers() {
var d = new ActionDescriptor();
d.putEnumerated(stringIDToTypeID("apply"), stringIDToTypeID("autoBlendType"), stringIDToTypeID("maxDOF"));
d.putBoolean(stringIDToTypeID("colorCorrection"), true);
d.putBoolean(stringIDToTypeID("autoTransparencyFill"), false);
executeAction(stringIDToTypeID("mergeAlignedLayers"), d, DialogModes.NO);
};
function SaveTIFF(saveFile) {
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
};
function selectAllLayers() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc.putReference(charIDToTypeID('null'), ref);
executeAction(stringIDToTypeID('selectAllLayers'), desc, DialogModes.NO);
};
function stackFiles(sFiles) {
var loadLayersFromScript = true;
var SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize('$$$/ScriptingSupport/InstalledScripts=Presets/Scripts'));
$.evalFile(new File(SCRIPTS_FOLDER + '/Load Files into Stack.jsx'));
loadLayers.intoStack(sFiles);
};
function autoAlign() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc.putReference(charIDToTypeID('null'), ref);
desc.putEnumerated(charIDToTypeID('Usng'), charIDToTypeID('ADSt'), stringIDToTypeID('ADSContent'));
desc.putEnumerated(charIDToTypeID('Aply'), stringIDToTypeID('projection'), charIDToTypeID('Auto'));
desc.putBoolean(stringIDToTypeID('vignette'), false);
desc.putBoolean(stringIDToTypeID('radialDistort'), false);
executeAction(charIDToTypeID('Algn'), desc, DialogModes.NO);
};
function autoBlend() {
var desc = new ActionDescriptor();
desc.putEnumerated(charIDToTypeID('Aply'), stringIDToTypeID('autoBlendType'), stringIDToTypeID('maxDOF'));
desc.putBoolean(charIDToTypeID('ClrC'), true);
executeAction(stringIDToTypeID('mergeAlignedLayers'), desc, DialogModes.NO);
};
... View more