|
Post by Bailey on May 26, 2019 1:03:11 GMT
In the past, I have posted my PSE scripts in different threads. It is much more user friendly to put them in a single thread which is what this thread is about. If any of these scripts are of any use to you, feel free to download them, edit them and use them as you wish. To run any of these scripts: 1. Copy/paste the code into a plain text file using your favourite text editor. MS Notepad, Wordpad or the Mac. equivalents should be fine. I don't recommend MS Word. 2. Save the text file with any name you like to any folder your like on your PC. Ensure the filename has a .jsx extension. 3. Launch PSE and open one or more image files in the editor. 4. Select File -> Open from the PSE main menu. 5. Navigate to your plain text .jsx script file and select it. The script will then run automatically. ORYou can add custom scripts to the File -> Automation Tools menu.
|
|
|
Post by Bailey on May 26, 2019 1:25:31 GMT
** Open Files as Smart Object Layers **This script prompts the user to select image files to be opened as individual smart object layers in a single layer stack in a new document. You also have the option to close the selected files after they have been added as layers and/or simplify the new smart object layers.
saveInitAppSettings(); setPixelUnits(); var file2PlaceA = [] /*--------------------------------------------------------------- Create the dialog box ---------------------------------------------------------------*/ var dlg = new Window( "dialog", "Open Images As Layers" ); dlg.size = [ 400, 350 ]; dlg.resizeable = true; dlg.listPnl = dlg.add('panel', undefined, 'Selected Files'); dlg.listPnl.orientation = 'row' dlg.listPnl.alignChildren = ['','top']; dlg.listPnl.browseBtn = dlg.listPnl.add('button', undefined, 'Add More Files'); dlg.listPnl.filesList = dlg.listPnl.add('listbox',undefined); dlg.listPnl.filesList.preferredSize=[140,280]; dlg.listPnl.filesList.maximumSize.height = 150; dlg.chkBoxGrp = dlg.add('panel',undefined,'',{borderStyle:'none'}); dlg.chkBoxGrp.orientation = 'column'; dlg.chkBoxGrp.alignChildren = ['left','']; dlg.chkBoxGrp.chkCloseFiles = dlg.chkBoxGrp.add('checkbox',undefined,'Close selected files after opened as layers'); dlg.chkBoxGrp.chkSimplifyFiles = dlg.chkBoxGrp.add('checkbox',undefined,'Simplify smart object layers'); dlg.btnPnl = dlg.add('panel', undefined, ''); dlg.btnPnl.orientation = 'row'; dlg.btnPnl.alignChildren = ['','top']; dlg.btnPnl.cancelBtn = dlg.btnPnl.add('button', undefined, 'Cancel'); dlg.btnPnl.submitBtn = dlg.btnPnl.add('button', undefined, 'Submit'); dlg.btnPnl.submitBtn.enabled = false; dlg.btnPnl.submitBtn.addEventListener('click',runSubmit); // **** add event handlers **** dlg.btnPnl.cancelBtn.addEventListener('click',cancelScript); dlg.listPnl.browseBtn.addEventListener('click',function(){ file2PlaceA = file2PlaceA.concat(promptUser2SelectFiles()); addFiles2ListBox(file2PlaceA); }); dlg.show(); //======================================================== function runSubmit (){ var maxDimsA = getMaxLengthHeight(file2PlaceA); var newDoc = app.documents.add(maxDimsA[0], maxDimsA[1], maxDimsA[2]); //create a blank document app.activeDocument = newDoc; putImages2SmartLayers(file2PlaceA); resetAppSettings(); dlg.close(); } function promptUser2SelectFiles(){ var selectedFiles = []; do{ //prompt user to select files var srcFiles = app.openDialog(); selectedFiles = selectedFiles.concat(srcFiles); var strAns = confirm('Would you like to select more files from another folder?'); } while(strAns === true); return selectedFiles; } function cancelScript(){ resetAppSettings(); dlg.close(); exit(); } function saveInitAppSettings() { startRulerUnits = app.preferences.rulerUnits; startTypeUnits = app.preferences.typeUnits; var startDisplayDialogs = app.preferences.displayDialogs; } function setPixelUnits() { app.preferences.rulerUnits = Units.PIXELS; app.preferences.typeUnits = TypeUnits.PIXELS; } function resetAppSettings() { app.preferences.rulerUnits = startRulerUnits; app.preferences.typeUnits = startTypeUnits; } function addFiles2ListBox(file2PlaceA){ dlg.listPnl.filesList.removeAll(); //first clear the listbox of any items for(i=0;i<file2PlaceA.length;i++){ dlg.listPnl.filesList.add('item',file2PlaceA[i].name); } toggleSubmitBtn(); dlg.visible = true; } function putImages2SmartLayers(docs2PlaceA){ for (var i = 0; i < docs2PlaceA.length; i++) { var idPlc = charIDToTypeID("Plc "); var desc13 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); desc13.putPath(idnull, docs2PlaceA[i]); var idFTcs = charIDToTypeID("FTcs"); var idQCSt = charIDToTypeID("QCSt"); var idQcsa = charIDToTypeID("Qcsa"); desc13.putEnumerated(idFTcs, idQCSt, idQcsa); var idOfst = charIDToTypeID("Ofst"); var desc14 = new ActionDescriptor(); var idHrzn = charIDToTypeID("Hrzn"); var idPxl = charIDToTypeID("#Pxl"); desc14.putUnitDouble(idHrzn, idPxl, 0.000000); var idVrtc = charIDToTypeID("Vrtc"); var idPxl = charIDToTypeID("#Pxl"); desc14.putUnitDouble(idVrtc, idPxl, -0.000000); var idOfst = charIDToTypeID("Ofst"); desc13.putObject(idOfst, idOfst, desc14); var idLnkd = charIDToTypeID("Lnkd"); desc13.putBoolean(idLnkd, true); executeAction(idPlc, desc13, DialogModes.NO); } if(dlg.chkBoxGrp.chkSimplifyFiles.value === true){ //simplify layers simplifyLayersInDoc(app.activeDocument); } } function getMaxLengthHeight(docsA) { var maxWH = [0, 0, 0]; //max width, height array - idx 0 = width, idx 1 = height, idx 2 = PPI for (var i = 0; i < docsA.length; i++) { //open file to get pixel dimensions var filePath = docsA[i].fullName; var tempFile = open(File(filePath)); if (tempFile.width.value > maxWH[0]) { maxWH[0] = tempFile.width.value; } if (tempFile.height.value > maxWH[1]) { maxWH[1] = tempFile.height.value; } if (tempFile.resolution > maxWH[2]) { maxWH[2] = tempFile.resolution; } if(dlg.chkBoxGrp.chkCloseFiles.value === true){ //close opened files tempFile.close(SaveOptions.DONOTSAVECHANGES) } } return maxWH } function simplifyLayersInDoc(docO){ for(i=0;i<docO.artLayers.length-1;i++){ docO.artLayers[i].rasterize(RasterizeType.ENTIRELAYER); } } function toggleSubmitBtn(){ if(dlg.listPnl.filesList.items.length>0){ dlg.btnPnl.submitBtn.enabled = true; }else{ dlg.btnPnl.submitBtn.enabled = false; } }
|
|
pontiac1940
CE Members
Posts: 6,359
Open to constructive criticism of photos: Yes
|
Post by pontiac1940 on May 26, 2019 1:26:22 GMT
That looks neat Bailey. Although I've had a computer at home for 35 years and once wrote simple BASIC programs (one to generate names for our new dog back in 1986...we ended up calling him Sam anyway ), my eyes glaze over at code. I hope I am not too old to learn or change, but I'll remain happy with what Adobe throws at me in PSE for basic editing. Perhaps I am a modern-day Luddite. This will surely interest some PSEM members. Thanks for the script. Clive
|
|
|
Post by Bailey on May 26, 2019 1:31:18 GMT
No problem Clive.
You're never too old to learn something new . I bought my first digital camera as recently as ~2006 ........feels like only yesterday
|
|
|
Post by Bailey on May 26, 2019 1:35:10 GMT
** Convert Files to 8 bit **Because Photomerge Panorama (in PSE 14 at least) requires files to be saved after converting to 8 bits before it can stitch them together, I have added a few extra lines of code to the original script to prompt whether the files are to be saved. If the files are saved, they are saved as PSD format files in the same folder the corresponding raw files are in. eg... myXYZ.cr2 (Canon raw file) will be saved as a PSD file named myXYZ.psd var numDocs = app.documents.length; //store the number of documents in the photo bin for(i=0;i<numDocs;i++){ //loop through the documents in the photo bin and change them all to 8 bit documents app.activeDocument = app.documents[i]; app.activeDocument.bitsPerChannel = BitsPerChannelType.EIGHT; } if(confirm('Would you like to save all the opened files?') === true){ //prompt to save files for(i=0;i<numDocs;i++){ //loop thru the docs in the photo bin and save them as a PSD app.activeDocument = app.documents[i]; app.activeDocument.saveAs(app.activeDocument.fullName,PhotoshopSaveOptions); } } alert("Script Complete");
|
|
|
Post by blackmutt on May 26, 2019 2:17:57 GMT
Can you show what the before & after is on these? Thanks
|
|
|
Post by Bailey on May 26, 2019 7:33:29 GMT
Hi blackmutt, Can you show what the before & after is on these? Thanks Thank you for your interest. A few people here and elsewhere have already downloaded some of the scripts. These scripts I originally write for my own purposes and to suit me and I am happy to share them for free with whoever might be interested. Consequently I can't justify the time to make and post screenshots for each script especially when for anyone interested it would take no more than 2-3 minutes for them to download a script and run it to see what it does. It would take me a lot more than a couple of minutes to make and post appropriate screenshots. Over time I will continue to add scripts to this thread.
|
|
|
Post by Bailey on May 26, 2019 11:32:48 GMT
... This will surely interest some PSEM members. Thanks for the script. ... and maybe some visiting non-members as well. When I look at the Home page's Users Online in the Last 24 Hours count, I always see very many more users coming here as "visitors" than registered members.
|
|
|
Post by hmca on May 26, 2019 13:39:52 GMT
Quite possibly I may be missing something but what I see is that you have created three different scripts/actions:
1. Create a dodge and burn layer. 2. Open files as smart objects. 3. Convert files to 8-bit.
So I don't understand the need for screen shots or pictures. With an action like the one Lillias has shared (creating a watercolor effect) I can see where a picture would be helpful. Just trying to understand Judy's question and your answer.
|
|
|
Post by blackmutt on May 26, 2019 16:16:43 GMT
I think what I am asking is for an example of what they do. Like the watercolor action. I can see the end result. Then I know if it is something I would be interested in worrying about.
|
|
|
Post by Bailey on May 27, 2019 6:48:49 GMT
Quite possibly I may be missing something but what I see is that you have created three different scripts/actions: 1. Create a dodge and burn layer. 2. Open files as smart objects. 3. Convert files to 8-bit. So I don't understand the need for screen shots or pictures. With an action like the one Lillias has shared (creating a watercolor effect) I can see where a picture would be helpful. Just trying to understand Judy's question and your answer. I think what I am asking is for an example of what they do. Like the watercolor action. I can see the end result. Then I know if it is something I would be interested in worrying about. hmca is correct in her assessment that screenshots are not required. The title and brief description of each script are self explanatory. I don't charge for these scripts. I create them for my own purposes and post them online for anyone to use as they see fit.
If someone interested doesn't have 2-3 minutes it would take to download them and run them (as I described in my OP) to see exactly what they do for themselves, that is fine. I have no problem at all with that. But then imho it is also unreasonable of them to expect me to spend much more than that time providing screenshots or whatever, especially when I don't charge for the scripts.
Over time I will be adding scripts to this thread and I am not planning to provide much more of a description for each one than what I have already done. As I mentioned earlier, I just cannot justify the extra time.
|
|
|
Post by Bailey on May 27, 2019 7:13:28 GMT
Quite possibly I may be missing something but what I see is that you have created three different scripts/actions: 1. Create a dodge and burn layer. 2. Open files as smart objects. 3. Convert files to 8-bit. ... I suspect you might be confusing scripts with actions. They are not the same physically. In the 3 scripts I am either looping through all the image files in the Photo Bin (scripts 1,3) and applying the script's task to each image file or prompting the user to select image files (script 2) on their computer as inputs for the script. Afaik you cannot do this with actions. Scripting also provides much more power and flexibility to perform tasks than actions can. But yes, I would suspect that every action could also be built using Javascript, but 100% certainly not every script can be reproduced as an action.
|
|
|
Post by hmca on May 27, 2019 11:33:50 GMT
Bailey, yes, I don't pretend to know the difference between a script and an action. I was only attempting to understand Judy's question. I have bought actions similar to the watercolor action that Lillias posted. They always come with an example/examples of what they can produce. If someone is given a clear idea of what your scripts can do then no example would be needed. In your case it would be up to the person, to decide if this was something, based on your description, that they wanted to download and try on their computer. I suppose it would also involve a certain trust in you as the producer of the script.
|
|
|
Post by Bailey on May 27, 2019 12:07:31 GMT
No problem hmca.
The big difference in your example of purchasing actions and me posting free scripts is that I am not charging for my scripts. If I did have a price on them then of course I would feel obliged to provide extra documentation on how to use the scripts and exactly what they do.
It is unreasonable for someone to expect me to spend a large amount of time putting together screenshots and extra information, since I don't charge for the scripts, when if someone is genuinely interested in trying a script then it would take them no more than 2-3 minutes maximum to do so.
If they don't trust me and/or my script then I have no problem with that at all. You can't be too careful with whatever you download from the www these days whether you pay for it or if it is free. That is why I always check for viruses first on anything I download, but that is another issue all together.
I explained earlier I can't justify the extra time it would take me to provide screenshots etc. It basically comes down to setting priorities for me. Providing extra information for my scripts is a very low priority for me, especially since I originally create them for my personal requirements and not for other people. I don't know how to make it any clearer than that.
|
|
Fauxtoto
Established Forum Member
Quebec, Canada
Posts: 440
Open to constructive criticism of photos: Yes
|
Post by Fauxtoto on May 27, 2019 13:23:23 GMT
Bailey, Technical computer stuff is not, at all, my cup of tea. For this reason, I will continue to use the PSE program as is. However, it seems to me that the topic you are raising with your scripts is original, relevant and interesting. Thank you for sharing.
|
|