Article View: adobe.photoshop.scripting
Article #477Re: Create strip from image sequence
From: Paul_R
Date: Thu, 05 Feb 2009 10:09
Date: Thu, 05 Feb 2009 10:09
127 lines
3774 bytes
3774 bytes
How about this Andrew, this is for png only. What it does is put a white pixel in each corner at .001 opacity so it doesn't show.
selectedFolder = Folder.selectDialog( "Please select input folder");
var fileList = selectedFolder.getFiles();
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
for(var a = 0; a<fileList.length;a++){
var file = fileList[a];
if(file instanceof File && file.name.match(/\.(png)$/i)){
open(file);
var Width = activeDocument.width.value;
var Height = activeDocument.height.value;
if(documents.length > 1){
var EXT = file.name.split('.');
var PNG = false;
if(EXT[1].toLowerCase() == 'png') PNG = true;
if(PNG) pinCorners();
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();
if(PNG) activeDocument.mergeVisibleLayers() else activeDocument.flatten();
}
}else{
continue;
}
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
}
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 );
};
function pinCorners(){
var Width =activeDocument.width.value;
var Height =activeDocument.height.value;
var fillColour = new SolidColor;
fillColour.rgb.hexValue = 'ffffff';
activeDocument.selection.select([[0,0],[1,0],[1,1],[0,1]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColour,undefined,.001);
activeDocument.selection.deselect();
activeDocument.selection.select([[(Width-1),0],[Width,0],[Width,1],[(Width-1),1]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColour,undefined,.001);
activeDocument.selection.deselect();
activeDocument.selection.select([[(Width-1),(Height-1)],[Width,(Height-1)],[Width,Height],[(Width-1),Height]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColour,undefined,.001);
activeDocument.selection.deselect();
activeDocument.selection.select([[0,(Height-1)],[1,(Height-1)],[1,Height],[0,Height]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColour,undefined,.001);
activeDocument.selection.deselect();
}
Technical Details
Message-ID:
<59b6a40f.16@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.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: Paul_R@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Re: Create strip from image sequence Message-ID: <59b6a40f.16@webcrossing.la2eafNXanI> Date: Thu, 5 Feb 2009 02:09:08 -0800 References: <59b6a40f.-1@webcrossing.la2eafNXanI> Lines: 75 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit