Copy link to clipboard
Copied
QUES 1
I may require a script to perform a certain function. One thing it will have to do is to paste a mask into the channel layer of a Smart filter. i.e. When a Smart filter is created, an additional channel layer associated with the Smart filter is also created to house any mask that is applied. That channel is created with visibility turned off. To paste into that channel layer, the visibility has to be turned on, the mask pasted in, and the visibility turned off again.
I'm not asking how to do it, but whether it is a straighforward job to do such a thing in a script.
QUES 2
In terms of getting help from this forum, does it matter if I use Applescript or Javascript? Which do most people use? Do script writers specialise in one or the other?
The Action Manager is a way to deal with some things that can not be done with normal scripting. Details are in the javascript guide. You can use the scriptlistner plugin that ships with Photoshop to create code from things you do in Photoshop. You do not use actions. For example below is a javascript function that makes the channel mask active and shows the mask
...function selectLayerMask(){
var rc = false;
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.pu
Copy link to clipboard
Copied
You can work with a channel mask using scripting. But it has to be done with the Action Manager API. I can post some examples if you like.
I would recommend that you use javascript for several reasons. First it is cross platform, second there seems to be more people on the forums using JS than AS, and last but not least in this case you can not work with the Action Manager API using AS. You would have to create and call JS funcions from AS.
Copy link to clipboard
Copied
Re Action Manager API: I have no idea what that is. Are you saying that to do what I mentioned, you have to record an action, and that action can be accessed by a script. i.e. a script cannot of itself say: "make visible the channel layer that Photoshop just created when I asked PS to Convert for Smart Filters".
Copy link to clipboard
Copied
The Action Manager is a way to deal with some things that can not be done with normal scripting. Details are in the javascript guide. You can use the scriptlistner plugin that ships with Photoshop to create code from things you do in Photoshop. You do not use actions. For example below is a javascript function that makes the channel mask active and shows the mask
function selectLayerMask(){
var rc = false;
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Msk " ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putBoolean( charIDToTypeID( "MkVs" ), true );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
rc = true;
} catch (e) {
if (!e.toString().match(/Select.+is not currently available/)) {
throw e;
}
}
return rc;
}
Copy link to clipboard
Copied
Thanks for the info, Michael. I checked out the Scripting Guide you mentioned, and even though you said "you do not use actions", the Guide seems to say you do. But I've probably misunderstood something. Here is what it says in part:
To make the Emboss filter scriptable:
1. Open Photoshop, then open a document.
2. Choose Window > Actions, then choose New Action from the Actions palette menu.
3. Name the action, then click Record.
4. Choose Filter > Stylize > Emboss.
Aside from that, you've answered my question -- this scripting is beyond me. I'll have to choose either to pay someone to write me a script, or tackle what I want to do manually.
Copy link to clipboard
Copied
I should have said that you do not need to use actions. You can record what you like in an action then call that action from a script. But actions are not needed. You can use scriptlistner( action manager ) code to do what the action would do.
Copy link to clipboard
Copied
Guy. Your Question 1 is best answered this way - that scripting is not necessary at all. Its possible to do it all with Actions, there's a step "Set current layer to: with filter mask enabled" - so your entire process can be an Action. (Great to see they have updated Actions correctly in CS4 to record these new features)
Generally don't be fooled into ASSUMING that just because steps seem complex, that they need scripting. Actions are much more powerful than most users realise. Scripting is best used for conditional, non-linear steps, or where other applications are involved. Actions also have the added advantage that they run faster, and are easily triggerable with keyboard or panels.
Copy link to clipboard
Copied
Scripts can also be triggered by keyboard via actions and in Flex panels directly. When you say that actions are faster, do you mean faster than scripts? On what information do you base that claim?
However and more to the point, Guy posted his question on a scripting forum and ask 'Can a script change...'. It seems to me that you are the one doing the assuming that Guy is unaware of actions.
Copy link to clipboard
Copied
When you say that actions are faster, do you mean faster than scripts? On what information do you base that claim?
Experience. Scripts have to read off the disk, as far as I'm concerned this slight delay is annoying enough to make Actions a better option. Certainly where everyday workflow is involved. Actions play instantly and can as a result be built into workflow better, shortcutted.
Guy posted his question on a scripting forum and ask 'Can a script change...'.
Fair point I guess. But when Actions are clearly the best solution its best to point it out. It was more a response to your repeated advice "you do not need to use actions." My response is, as it is in 80% of these situations, "you do not need to use scripts"
Theres a good reason for this… most users have absolutely no idea how powerful Actions are, how easy they are to customise, or work with. That they can be used to record pretty well ANY linear workflow. And as a result try to step into the complex world of scripting too early, and get discouraged as a result. Thinking that scripting is the ONLY solution to complex linear problems is not constructive.
And of course I'm aware of how to trigger scripts.
Copy link to clipboard
Copied
Scripts have to read off the disk, as far as I'm concerned this slight delay is annoying enough to make Actions a better option. Certainly where everyday workflow is involved. Actions play instantly and can as a result be built into workflow better, shortcutted.
Do you actually have empircal rather than anecdotal evidence? If you can notice a performance difference because of a script being read off the disk, you either have a very very slow disk (e.g < 5400rpm) or a very very large script (>>100KLOC*).
If you are not recording actions that call scripts (or writing scripts that call actions), you're not taking full advantage of both. Actions that call scripts can be as easily integrated into your workflow as actions that don't.
It was more a response to your repeated advice "you do not need to use actions."
The advice "you do not need to use actions" was (probably) meant more to reduce the overall complexity of the solution, especially if the solution is to be shared with others. If you have to have a script (because you're looping over layers, or whatever) there are likely parts of the script that could be implemented as actions. Is it easier to provide/package a 300LOC* script that requires a half dozen actions to be present or is it easier to provide a 400LOC script?
And as a result try to step into the complex world of scripting too early, and get discouraged as a result.
True. That is why Mike, I, and others regularly recommend using actions instead of scripts. But, as you noted, not everything is recordable in actions and what is recordable varies from version to version of PS. I've repeatedly said that the best script is the one you don't have to write, but often times it is unavoidable.
Thinking that scripting is the ONLY solution to complex linear problems is not constructive.
But it is the only solution to some linear problems, regardless of their complexity. A trivial example is placing the name of the document into the Title metadata field.
-X
*LOC = lines of code, KLOC = thousand lines of code
Copy link to clipboard
Copied
But it is the only solution to som linear problems, regardless of their complexity.
Well - I'd like to know which linear problems you happen to think fall into that category? I have a history of going through this forum and thinking "yep… time wasters - actions would be a better answer" - maybe things have improved, because haven't been here for a while.
I, and others regularly recommend using actions instead of scripts.
Good to hear
Do you actually have empircal rather than anecdotal evidence? If you can notice a performance difference because of a script being read off the disk, you either have a very very slow disk (e.g < 5400rpm) or a very very large script (>>100KLOC*)
Most high end users (retouchers, or people who know what they are doing) use actions to streamline workflow. Not just for one off processes, but for basics. Its got to be LIGHTNING fast, because you have to work at that speed. The first time you summon a script - theres a slight pause while it searches for, and calls up the script. At the moment my machine is a quad intel mac, so there are really no faster drive machines available.
Copy link to clipboard
Copied
Well - I'd like to know which linear problems you happen to think fall into that category? I
I gave one later in my post.
A trivial example is placing the name of the document into the Title metadata field.
This was from a post either here or on ps-scripts.com. Adding a text layer with the image's name in it is a request that comes up about once a month or so.
Here's another example. A project that I am currently working on needs to apply a metadata template to a set of images. Recording an action will result in the values from the template file being stored in the action. What is really needed, in this case, is to be able to change the values in the template, rerun the action and have the new values applied to the image.
Yes, they're both metadata examples, but I've been doing a lot of metadata work lately so that's what I remember most readily.
I have a history of going through this forum and thinking "yep… time wasters - actions would be a better answer"
People ask for scripts for a number of different reasons.
The people that fall into the last category really aren't all that common, especially after traffic dropped off during the Jive conversion. And they usually get helped appropriately.
-X
Copy link to clipboard
Copied
BTW, I still come across (new) things in PS that can be recorded in Actions that previous required scripting. If you happen to come across post where this is true, by all means do let us know. Things change from version to version and I'm definitely not always current.
-X
Copy link to clipboard
Copied
When I said that 'you do not need to use actions' I was responding about using the action manager API in a script. Actions have thier place and I was not suggesting that they should never be used. I only meant that if you where script the workflow that you could script anything that can be done in an action and that you do not need to use both.
Guy may be able to do what his workflow requires by actions alone. It's possible that he could not, which may be the reason he asked about scripting. I was trying to answer his question about if something could be done with scipting and which is better applescript or javascript.
I agree that actions are powerful and that people some times think that they need to script something that could be done with actions alone. Had he asked 'How to change the visibility on a mask' I may have responded differently. To my mind, by the wording of his post, it was clear that he wanted a scripting solution.
Copy link to clipboard
Copied
Guy may be able to do what his workflow requires by actions alone. It's possible that he could not,
No thats not possible, and I gave the answer in post 6 - what he wants is easy to achieve with an Action. The fact is that nearly everything that people practically need to do in linear terms is possible with Actions- its really extremely rare that this is not the case. If anyone can provide me with examples where they can find a linear process in Photoshop is not Actionable, (multiple document juggling, liquify, excepted obviously) then I'm up for the challenge!
I agree that actions are powerful and that people some times think that they need to script something that could be done with actions alone.
To be honest I think we are all on the same page, if that's the general view here these days.
Copy link to clipboard
Copied
xbytor2-
BTW, I still come across (new) things in PS that can be recorded in Actions that previous required scripting.
Things change from version to version and I'm definitely not always current.
Nah, you are CONVINCING yourself of this. I assure you, I've been an Actions power user for years - there are really no examples where they have made things recordable that weren't before. This forum has, in certain important respects, been barking up completely the wrong tree for years. You may fall into the category of someone who, deceived, didn't realise the power of actions all along.
A trivial example is placing the name of the document into the Title metadata field.
Thats what I call a conditional, its conditional on the name of the file. The other metadata example - have you tried Bridge at all?
People ask for scripts for a number of different reasons.
- They are learning
- They are curious
- They have an existing script that needs to be enhanced
- They are on a version of PS that can't record what they need
- They don't know any better
I would add…
• They don't know what Actions are capable of
As for "• They are on a version of PS that can't record what they need" - no such thing, see above
Copy link to clipboard
Copied
I assure you, I've been an Actions power user for years - there are really no examples where they have made things recordable that weren't before.
Create a new document based on the properties of the current contents of the clipboard. In CS3, the properities of the clipboard are hardwired into the action. In CS4, it uses the 'Clipboard' preset which uses the properties of the clipboard at the time the action is run. Very handy. It's the most recent one that I ran across.
Thats what I call a conditional, its conditional on the name of the file.
A 'conditional' is more commonly defined as something that requires conditional execution such as an if-then-else construct. For instance, if doc.orientation is Portrait then do these steps else do some other steps.
• They don't know what Actions are capable of
That was my 'They don't know any better' item.
-X
Copy link to clipboard
Copied
Create a new document based on the properties of the current contents of the clipboard. In CS3, the properities of the clipboard are hardwired into the action. In CS4, it uses the 'Clipboard' preset which uses the properties of the clipboard at the time the action is run. Very handy. It's the most recent one that I ran across.
Piffle - its been possible to do this since at least Photoshop version 5 - created back in 1998
Copy link to clipboard
Copied
Piffle - its been possible to do this since at least Photoshop version 5 - created back in 1998
How? I am seeing two different things being recorded for CS3 and CS4. If the clipboard contents are identical when the action is recorded and later played back, it doesn't matter. But if the clipboard is a different size, the results are completely different.
-X
Copy link to clipboard
Copied
How? I am seeing two different things being recorded for CS3 and CS4. I
No your not. believe me. People just have no IDEA how massively powerful action based customizability actually IS. And always has been.
Copy link to clipboard
Copied
Here's what is looks like in CS3
And here's what it looks like in CS4
Looks kinda different to me.
-X
Copy link to clipboard
Copied
okaaaay - yes looks like there is a change there, its now possible to record, basing document res on dynamic clipboard in CS4. I wasn't reading the post properly, and to be honest had no idea of this change. Though do seem to remember doing this as part of actions back in the day without problems, its POSSIBLE that it was changed at some point the wrong way. Ok fair enough on that one.
Copy link to clipboard
Copied
X, if this was on usenet someone would have already called him a troll.
Copy link to clipboard
Copied
I'm actually interested in a response to the Clipboard question. I've finally started doing all of my work in CS4 (because of debugging improvements) and got bit by this when I tried to back-port to CS3. I was fortunately able to code around being able to specify the Clipboard preset but I'd rather not have to in the future.
-X
Copy link to clipboard
Copied
The other metadata example - have you tried Bridge at all?
Yep. I'm fairly familiar with it. But this is an operation in PS that is not recordable, which was the question at hand. The solution in Bridge would require using the UI (and allowing multiple updates in one pass) or would require using a script.
Another category of operations that can't be recorded are anything dealing with Actions (e.g. loading, saving, renaming, etc...). Admittedly, it's rather rare that you would need this capability, but I have had the need more than once and I know there are others out there that have as well.
-X
Find more inspiration, events, and resources on the new Adobe Community
Explore Now