c.pfaffenbichler
Community Expert
c.pfaffenbichler
Community Expert
Activity
‎Mar 24, 2009
03:47 AM
Paste it into a new file in ExtendScript Toolkit and save it as a jsx-file. (ExtendScript Toolkit should have been automatically installed when You installed Photoshop.)
You can run it by hitting the play-button in the windows upper bar or place it in Photoshop Presets Scripts.
But it doesnt strictly belong to Photoshop as it does nothing within that program.
Please try it on a duplicate-folder first for testing-purposes.
... View more
‎Mar 24, 2009
01:11 AM
This might help:
var theFolder = Folder.selectDialog("select the folder containing the images to be renamed");
if (theFolder) {
var theFiles = theFolder.getFiles();
for (var m = 0; m < theFiles.length; m++) {
var theName = theFiles .name;
var theLastNumbers = theName.slice( theName.lastIndexOf("_") + 1, -4);
var theRest = theName.slice(0, theName.lastIndexOf("_"));
theFiles .rename(theLastNumbers + "_" + theRest + ".jpg")
}
};
else {
alert ("no selection")
};
use it at Your own risk
Edit: Actually it should include some function to ascertain that the files are indeed jpgs or at least retain the original suffix.
Still if the folder contains only jpgs it should work.
... View more
‎Mar 22, 2009
04:21 AM
Adapting that Script might be somewhat difficult as it is pretty bulky.
But if its always the topmost layer thats supposed to stay visible and You know which format You want to save the resulting files to beforehand something much smaller may suffice.
You might try this, but I havent tested it extensively:
#target photoshop;
var myDocument = app.activeDocument;
// get the name and location;
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var docPath = myDocument.path;
// get the artlayers and remove the topmost;
var allArtLayers = collectLayers(myDocument);
var theTopmost = allArtLayers.pop();
// hide all but the topmost layer;
for (var n = 0; n < allArtLayers.length; n++ ) {
allArtLayers .visible = false
};
for (var m = 0; m < allArtLayers.length; m++ ) {
// show the layer;
allArtLayers .visible = true;
// tiff options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS ;
tifOpts.layers = true;
// duplicate the image;
var thecopy = myDocument.duplicate (thecopy, true);
// save copy;
thecopy.saveAs((new File(docPath+"/"+basename+" "+allArtLayers .name+".tif")),tifOpts,true);
thecopy.close(SaveOptions.DONOTSAVECHANGES);
// hide the layer again;
allArtLayers .visible = false
//thats it; thanks to xbytor;
};
////// collect all artlayers //////
function collectLayers (theParent) {
if (!allArtLayers) {
var allArtLayers = new Array}
else {};
for (var m = theParent.layers.length - 1; m >= 0;m--) {
var theLayer = theParent.layers ;
// apply the funtion to layersets;
if (theLayer.constructor == ArtLayer) {
allArtLayers = allArtLayers.concat(theLayer)
}
else {
allArtLayers = allArtLayers.concat(collectLayers(theLayer))
}
};
return allArtLayers
};
... View more
‎Mar 21, 2009
06:01 AM
Luis, isnt going via Smart Objects more time-intensive than grouping the layer and then merging the resulting group?
But of course that would trash existing Clipping Masks
... View more
‎Mar 21, 2009
01:08 AM
In that case treating the groups as layers should work out as long as their names follow the same conventions.
The visibility of the layers inside the groups should not get changed by turning the groups visibility on and off.
I guess.
... View more
‎Mar 19, 2009
12:14 AM
First: The headline to Your query is not very informative, a more specific definition of topic would seem a better choice.
Secondly: I havent tested it extensively and Im not very experienced with Scripting, but You could give this a try:
// this script tries to copy the clipping paths of files in one folder into files of the same name in another folder;
// use it at your own risk;
#target photoshop
var withPath = Folder.selectDialog("select the folder containing the images with paths");
var withoutPath = Folder.selectDialog("select the folder containing the images without paths");
if (!withPath || !withoutPath) {}
else {
var theOnesWith = withPath.getFiles();
var theOnesWithout = withoutPath.getFiles();
var notFound = new Array;
for (var m = 0; m < theOnesWith.length; m++) {
var checksOut = false;
theOne = theOnesWith ;
for (var n = 0; n < theOnesWithout.length; n++) {
theOtherOne = theOnesWithout ;
// compare file-names;
if (theOne.name.slice(theOne.name.lastIndexOf("/")+1,-4) == theOtherOne.name.slice(theOtherOne.name.lastIndexOf("/")+1,-4)) {
checksOut = true;
photoshop.open(theOtherOne);
var theUnpathed = app.activeDocument;
photoshop.open(theOne);
var thePathed = app.activeDocument;
for (var o = 0; o < thePathed.pathItems.length; o++) {
app.activeDocument = thePathed;
var aPath = thePathed.pathItems ;
// look for clipping path;
if (aPath.kind == PathKind.CLIPPINGPATH) {
aPath.select();
copyPath (thePathed, theUnpathed, aPath.name);
app.activeDocument = theUnpathed;
theUnpathed.pathItems[theUnpathed.pathItems.length-1].makeClippingPath(1)
}
else {}
}
}
else {};
try {
thePathed.close(SaveOptions.PROMPTTOSAVECHANGES);
theUnpathed.close(SaveOptions.PROMPTTOSAVECHANGES);
// for automatic saving clear previous line and remove the two slashes in the following line;
// theUnpathed.close(SaveOptions.SAVECHANGES);
}
catch (e) {};
}
if (checksOut == false) {
notFound = notFound.concat(theOne.name.slice(theOne.name.lastIndexOf("/")+1,-4))
}
else {}
};
if (notFound.length > 0) {
alert ("no corresponding file/s in the second folder found for \n" + notFound.join("\n"))
}
};
////// by nic bereznikov //////
function copyPath( From, To, PathName) {
// Select source document
activeDocument = From;
// define function
cTID = function(s) { return app.charIDToTypeID(s); };
// Select path
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( cTID( "Path" ), PathName);
desc.putReference( cTID( "null" ), ref );
executeAction( cTID( "slct" ), desc, DialogModes.NO );
// Copy path
executeAction( cTID( "copy" ), undefined, DialogModes.NO );
// Select destination document
activeDocument = To;
// Paste path
executeAction( cTID( "past" ), undefined, DialogModes.NO );
// Deselect path
//desc.putReference( cTID( "null" ), ref );
//executeAction( cTID( "Dslc" ), desc, DialogModes.NO );
}
... View more
‎Mar 15, 2009
08:32 AM
Regarding the nomenclature You can check out the Object Model Viewer in ExtendScript Toolkit or »Photoshop CS4 JavaScript Ref.pdf«.
The visibility of a LayeSet can be changed just like a Layers:
"app.activeDocument.layers["the groups name"].visibility = true"
And the matter can get difficult because a Layer is the child of a Document only if it does not reside in a LayerSet, in which case it is that LayerSets child, meaning one has to address it not as "app.activeDocument.layers["the layers name or index"]" but "app.activeDocument.layers["the groups name or index"].layers["the layers name or index"]" and so on, as far as I know.
How are the LayerSets and the ArtLayers organized with regard to the visibility demands for the jpgs?
... View more
‎Mar 15, 2009
05:35 AM
Youre welcome.
But I must admit I cut two corners:
Firstly I didnt sufficiently comment the posted Script, which I could remedy if You consider it necessary.
Secondly I supposed the numbers for Scenes and Subjects would be between zero and nine, so that slicing the last letter of the name should provide discernable identification for the newly saved files. With higher numbers some files would simply get replaced without notice. So it would be prudent to implement some method to grab the whole of the numbers.
... View more
‎Mar 12, 2009
10:57 PM
Provided none of the layers reside in a Layer Set, which would make things a bit more complicated, You could give this a try (»scene« and »subject« both in lower case though, You can change that easily in the Script):
#target photoshop
var myDocument = app.activeDocument;
var docName = myDocument.name;
var baseName = docName.match(/(.*)\.[^\.]+$/)[1];
var docPath = myDocument.path;
var jpgOptions = new JPEGSaveOptions();
jpgOptions.embedProfile = true;
jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgOptions.matte = MatteType.NONE;
jpgOptions.quality = 10;
theFolder = Folder.selectDialog("select a folder to save the jpgs to");
var theStart = myDocument.activeHistoryState;
var theScenes = new Array;
var theSubjects = new Array;
for (var m = 0; m < myDocument.layers.length; m++ ) {
var theLayerName = myDocument.layers .name;
switch (theLayerName.slice(0, 5)) {
case "scene": theScenes = theScenes.concat (theLayerName);
break;
case "subje": theSubjects = theSubjects.concat (theLayerName);
break}
};
for (var n = 0; n < myDocument.layers.length; n++ ) {
myDocument.layers .visible = false;
};
for (var o = 0; o < theScenes.length; o++ ) {
myDocument.layers[ theScenes ].visible = true;
for (var p = 0; p < theSubjects.length; p++ ) {
myDocument.layers[ theSubjects ].visible = true;
var theCopy = myDocument.duplicate (theCopy, true);
theCopy.bitsPerChannel = BitsPerChannelType.EIGHT;
theCopy.saveAs((new File(theFolder+"/"+baseName+"_"+theScenes .slice(-1)+"_"+theSubjects .slice(-1)+".jpg")),jpgOptions,true);
theCopy.close(SaveOptions.DONOTSAVECHANGES);
myDocument.layers[ theSubjects ].visible = false
};
myDocument.layers[ theScenes ].visible = false;
};
myDocument.activeHistoryState = theStart;
// thats it; thanks to xbytor;
// use it at your own risk;
... View more
‎Mar 12, 2009
02:44 AM
That doesnt sound too bad.
But how do You mark subject variation-layers as opposed to scene-layers?
Do they adhere to a naming-convention or are they stacked in a defined order (possibly in layer sets)?
Because obviously the Script would have to be able to identify the members of the two groups.
... View more
‎Mar 10, 2009
02:46 AM
I dont know why that should happen (maybe it was created in a different version), but You could record those steps Yourself and replace the old ones.
In the Actions Panel You should be able to read the original values for Select Modify Smooth and Select Modify Feather by clicking the small triangle to the left of the entries »Smooth« and »Feather«.
... View more
‎Mar 06, 2009
11:40 PM
When You copy the text into an ExtendScript Toolkit-file and save that into the Applications Adobe Photoshop CS4 - Presets Scripts-Folder it should be available under File Scripts after starting Photoshop again.
If You want to run the Script from ExtendScript Toolkit itself You have to select the program You want to target in the »Select the target application.«-field in the upper left field of the Document-window or include the line
#target photoshop
at the start of the Script.
Plus there are corrections in later posts that You should include at the proper positions.
... View more
‎Mar 06, 2009
01:26 AM
Maybe:
doc.exportDocument(new File("/c/"+ doc.layers[artlayers ].name +".jpg"), ExportType.SAVEFORWEB, options)
?
... View more
‎Mar 06, 2009
01:08 AM
Have You checked out this thread?
http://www.adobeforums.com/webx/.ef7f2c5.59b81817
... View more
‎Mar 05, 2009
10:42 AM
Please keep in mind though that, if a tiff of the respective name already exists in the folder, it will be replaced without asking!
... View more
‎Mar 05, 2009
04:27 AM
So it did »support the property or method 'colorProfileName'« after all?
... View more
‎Mar 04, 2009
10:32 PM
I used another profiles name, because I dont have the old one installed anymore, Youll have to be exact about the letters though.
And from a prepress-standpoint Id like to point out that removing the profile as opposed to »Convert to Profile« seems a peculiar practice, though of course Your reasons for doing so may be valid indeed.
You could try:
var myDocument = app.activeDocument;
if (myDocument.colorProfileName == "U.S. Web Coated (SWOP) v2") {
// =======================================================
var idassignProfile = stringIDToTypeID( "assignProfile" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idDcmn = charIDToTypeID( "Dcmn" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref1.putEnumerated( idDcmn, idOrdn, idTrgt );
desc2.putReference( idnull, ref1 );
var idmanage = stringIDToTypeID( "manage" );
desc2.putBoolean( idmanage, false );
executeAction( idassignProfile, desc2, DialogModes.NO );
}
else {
};
... View more
‎Mar 04, 2009
12:42 AM
Does the Error-message get recorded when opening with Scripting-Listener?
... View more
‎Mar 04, 2009
12:26 AM
Im not quite sure I understand Your question completely, but the best I could come up with for checking if a profile is embedded in a file is a try-clause (which is bad form):
var myDocument = app.activeDocument;
try {
myDocument.colorProfileName;
alert ("profile embedded\n" + myDocument.colorProfileName)
}
catch (e) {
alert ("no profile embedded")
};
Hopefully one of the more experienced scripters will chime in.
... View more
‎Mar 03, 2009
01:37 AM
This checks for eps only by using the name, so if other files mistakenly are named ».eps« it probably would cause problems, and I havent provided a provision for avoiding over-writting existing tiffs of the same names, but You could give this a try:
#target photoshop;
var dlg = new Window('dialog', "save flattened tiffs of eps-files", [500,300,880,525]);
//filter for checking if entry is numeric, thanks to xbytor;
numberKeystrokeFilter = function() {
this.text = this.text.replace(",", ".");
if (this.text.match(/[^\-\.\d]/)) {
this.text = this.text.replace(/[^\-\.\d]/g, '');
}
};
//create the entry for resolution;
dlg.msgPnl = dlg.add('panel', [25,100,355,170], 'resolution');
dlg.msgPnl.msgEt = dlg.msgPnl.add('edittext', [15,20,135,40], 150, {multiline:false});
dlg.msgPnl.msgEt.onChange = numberKeystrokeFilter;
//create a field for folder-selection;
dlg.folderPnl = dlg.add('panel', [25,25,355,90]);
dlg.folderPnl.btn = dlg.folderPnl.add('button', [12,7,313,17], 'select a folder to process', {name:'remove'});
dlg.folderPnl.folderName = dlg.folderPnl.add('statictext', [12,35,313,55], "none selected", {multiline:false});
// select a folder-function;
function folderSelection (theFolder) {
var theFolder = Folder.selectDialog ("select a folder");
dlg.folderPnl.folderName.text = String(theFolder);
};
dlg.folderPnl.btn.onClick = folderSelection;
//fields for ok and cancel;
dlg.buildBtn = dlg.add('button', [25,185,175,195], 'OK', {name:'ok'});
dlg.cancelBtn = dlg.add('button', [185,185,355,195], 'Cancel', {name:'cancel'});
// show dialog;
var myReturn = dlg.show ();
//////////// the operation //////////////////
if (myReturn == true && dlg.folderPnl.folderName.text != "none selected") {
// retrieve file-list and resolution;
var theFolder = dlg.folderPnl.folderName.text;
var theFileList = Folder(theFolder).getFiles();
var theResolution = dlg.msgPnl.msgEt .text;
// do the thing;
for (var m = 0; m < theFileList.length; m++) {
// getting the name and location;
var docName = theFileList .name;
var docPath = theFileList .path;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
// open only files whose names end on ».eps«;
if (docName.slice(-4) == ".eps") {
// =======================================================
var idOpn = charIDToTypeID( "Opn " );
var desc1 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc1.putPath( idnull, new File( theFileList ) );
var idAs = charIDToTypeID( "As " );
var desc2 = new ActionDescriptor();
var idRslt = charIDToTypeID( "Rslt" );
var idRsl = charIDToTypeID( "#Rsl" );
desc2.putUnitDouble( idRslt, idRsl, theResolution );
var idAntA = charIDToTypeID( "AntA" );
desc2.putBoolean( idAntA, true );
var idEPSG = charIDToTypeID( "EPSG" );
desc1.putObject( idAs, idEPSG, desc2 );
executeAction( idOpn, desc1, DialogModes.NO );
// define the copy:
var theCopy = app.activeDocument;
// tiff options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
// make a copy, flatten it, delete paths, set it to 8bit;
theCopy.flatten();
theCopy.bitsPerChannel = BitsPerChannelType.EIGHT;
// save it;
theCopy.saveAs((new File(docPath+"/"+basename+".tif")),tifOpts,true);
theCopy.close(SaveOptions.DONOTSAVECHANGES);
}
else {}
}
};
// use it at your own risk;
If any of You spot unnecessary or stupid operations in the Script please let me know.
... View more
‎Feb 27, 2009
06:13 AM
Yeah, well, took me some time to notice Your query
Hope it helps though.
... View more
‎Feb 27, 2009
03:20 AM
"~/Desktop/ /Filename"<br />or <br />"/Volumename/Foldername//Filename"<br />I guess. (With »« meaning: The names of the folders in sequence.) <br />But be aware that spaces and other keys might cause problems. <br /><br />Or do You mean You want to be allowed to select a file? <br />In which case I would use: <br />var theFile = File.openDialog ("open", false);<br />photoshop.open(theFile);<br /><br />And for more files one could use:<br />var theFiles = File.openDialog ("open", true);<br />for (var m=0; m<theFiles.length; m++) {<br />photoshop.open(theFiles )<br />};
... View more
‎Feb 19, 2009
01:46 AM
Well, any irregular shape will produce different results with Scaling instead of Offsetting, even rectangles (edit: with the exception of the square).
Doesnt it seem a bit strange though to have to try and mathematically recreate a function that already exists in Illustrator?
Albeit regrettably out of Scriptings reach, it seems.
... View more
‎Feb 18, 2009
08:15 AM
WEP, as I understand it Offset Path and Scaling are two very different things.
If for example one had a form with a hole, Offset Path (with a positive value) would close that hole at some point, whereas Scaling would never close the hole.
... View more
‎Feb 17, 2009
11:56 PM
First off I dont know of any such plugin and am not an experienced scripter, so Im no help here.
But the problem certainly sounds interesting.
In principle I guess it should not be beyond Photoshop/Scriptings reach to recognize some defined forms and use them as basis for a perspectival transformations, because that seems to be one of the operations »Photomerge« accomplishes.
But how to make it recognize distorted rectangles (possibly with crooked and broken lines depending on the ornamentation and form of the frame), which arent even necessarily of the same proportions, and define the amount of correction seems pretty close to unfathomable to me.
As of now I guess Youre better off doing it manually and automate whatever else is possible to speed up the process.
Was it a studio-shoot or done on location?
... View more
‎Feb 17, 2009
11:32 PM
I work on a Mac, so it might be different with Your setup, but my »ExtendScript Toolkit 2«-Folder containa a Folder »SDK«, which contains a pdf named »Adobe Intro to Scripting.pdf«.
But I think all those instructional pdfs are also available as downloads; have You googled it already?
... View more
‎Feb 12, 2009
08:58 AM
Now that makes me curious have You all struck it rich and (semi-)retired early or are You actually venerable old-age-pensioneers?
... View more
‎Feb 12, 2009
06:32 AM
Actually I would consider You one of them, Paul.
... View more
‎Feb 12, 2009
02:31 AM
All the necessary steps appear scriptable in JavaScript too.
There are a couple of pros frequenting this forum who, Im certain, could provide such a Script easily and speedily.
... View more
‎Jan 29, 2009
10:43 PM
Compliments on a great and greatly useful script!
Thanks,
pfaffenbichler
... View more