Article View: adobe.photoshop.scripting
Article #481Re: Create strip from image sequence
From: Andrew_Souter
Date: Thu, 05 Feb 2009 17:18
Date: Thu, 05 Feb 2009 17:18
88 lines
4375 bytes
4375 bytes
Here is my attempt to batch process folders:
_____________________________________________________________________________
//////////////////////////////////////////////////////////////////////////////////////////////////
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
//////////////////////////////////////////////////////////////////////////////////////////////////
selectedFolder = Folder.selectDialog( "Please select input folder");
var folderList = selectedFolder.getFolders();
for(var aFolder = 0; aFolder<folderList.length;aFolder++) { var theFolder = folderList[aFolder];
var fileList = theFolder.getFiles();
for(var aFile = 0; aFile<fileList.length;aFile++) { var file = fileList[aFile];
if(file instanceof File && file.name.match(/\.(jpg|tif|gif|png)$/i))
{
open(file);
////////////////////////////////////////Add Extra Boarder Stripe to maintain relative positon
var Width =activeDocument.width.value;
var Height =activeDocument.height.value;
activeDocument.resizeCanvas(Width+2, Height, AnchorPosition.MIDDLECENTER)
var Width =activeDocument.width.value;
var Height =activeDocument.height.value;
var fillColor = new SolidColor;
fillColor.rgb.hexValue = '000000';
activeDocument.selection.select([[0,0],[1,0],[1,Height],[0,Height]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColor, ColorBlendMode.NORMAL, 100, false );
activeDocument.selection.deselect();
activeDocument.selection.select([[(Width-1),0],[Width,0],[Width,Height],[(Width-1),Height]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColor, ColorBlendMode.NORMAL, 100, false );
activeDocument.selection.deselect();
////////////////////////////////////////
if(documents.length > 1)
{
////////////////////////////////////////Add to Frame Strip
activeDocument.selection.selectAll();
activeDocument.selection.copy();
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
activeDocument = documents[0];
app.activeDocument.resizeCanvas(app.activeDocument.width,app.activeDocument.height+Height, AnchorPosition.TOPCENTER);
activeDocument.paste();
activeDocument.selection.selectAll();
align('AdBt');
app.activeDocument.selection.deselect();
activeDocument.mergeVisibleLayers();
////////////////////////////////////////
}
}else
{
continue;
}
}
////////////////////////////////////////Remove Extra Boarder Stripe and Save
var Width =activeDocument.width.value;
var Height =activeDocument.height.value;
activeDocument.resizeCanvas(Width-2, Height, AnchorPosition.MIDDLECENTER)
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM FUNCTIONS
//////////////////////////////////////////////////////////////////////////////////////////////////
function align(method) {
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" ), charIDToTypeID( method ) );
executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
};
_____________________________________________
I get an error stating .getFolders is not a valid function.... Any idea how to get a list folders in a parent folder in Javscript and iternate through these? On OSX?
I can do it with AppleScript, but I can't code the things needed above with appleScript...
Technical Details
Message-ID:
<59b6a40f.19@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b6a40f.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,62960464640e583b X-Google-Attributes: gidf5839,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Andrew_Souter@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Re: Create strip from image sequence Message-ID: <59b6a40f.19@webcrossing.la2eafNXanI> Date: Thu, 5 Feb 2009 09:18:17 -0800 References: <59b6a40f.-1@webcrossing.la2eafNXanI> Lines: 110 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit