Skip to main content
bostclair
Participant
October 16, 2017
Question

Is it possible to create Photoshop script to duplicate a current layer to a new doc, convert to grayscale, then duplicate it back to the original doc?

  • October 16, 2017
  • 1 reply
  • 416 views

I cannot seem to achieve this through actions. Since these are all different files with different names, I could not figure how to duplicate layer back to the 'previous or original' file without calling it by name Just wondered if this is even doable? Searching Apple Scripts, I still could not find the exact terminology I was looking for. Thanks for any help or advise.

~Bo

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
October 16, 2017

Yes and you should be able to do that in an action.  You  need to know when you duplicate a layer into a new document the new document becomes Photoshop active document and you need to know  how the get  the ddocument you player the action on the be Photoshop active document again so you can work on it and add the layer to.  Since Actions can not use logic you need to switch between document in a relative manner.

Why not duplicate the layer in the current document. Convert the duplicated layer into a grayscale layer and then duplicate that layer into a new document that then becomes the active document till you select the previous document or save and close the new document to switch back to the document you player the action on.

Actions are a series of Photoshop steps.  If you duplicate a layer into a new document that new document is added into the open document ring in Photoshop and becomes the active document.  If you do not first dupe and convert the dupe to grayscale instead dupe into a new document then convert to grayscale the only  ways to get the layer back into the previous document is copying the layer into the clipboard switch back to the previous  document and paste in a new layer.  IMO it is better not to use the clipboard and best not to use select previous and next document in actions when possible.  For if an actions opens other documents in Photoshop where select next or previous document which document becomes the active document can change.  You need to be very careful of the sequence and better not use steps like play and script within the sequence. 

Scripts are like Actions that can user logic.  A script can keep track of documents and set which document they want active to work.  Scripts are programs written in a script language.  JavaScript is the only script language Photoshop supports the  works across both platforms Mac and Windows.   Even then  a script may need special code to test platform because there are some differences between OS systems.  

Writing your own Photoshop script requires you know how Photoshop works well and you need to be a Programmers do you know JavaScript.

Most Photoshop users never write a Photoshop script they only use scripts that ship with Photoshop or other provide.  Like Photomerg, Load File into stack, Image Processor,  Lens correction ... ETC.

JJMack
Jarda Bereza
Inspiring
October 16, 2017

Yes. This is possible with scripting. Not sure if this is possible only with actions.