Copy link to clipboard
Copied
Hi guys,
I am new to scripting for Photoshop. I am using Javascript.
How do I write code in Javascript to open a file (e.g. a jpeg) in Photoshop? And how do I write code to save it as e.g. a PSD, EPS etc?
Will really appreciate the help.
Thanks.
Thanks Stephen, let me give @Joseph25509234xr72 some extra-context.
The scripting code in the replies above is ExtendScript (an Adobe-proprietary flavour of JS based on a very old language specification). Since late 2020, Photoshop has been transitioning to UXP, which uses modern JavaScript. ExtendScript is going to be faded out (ETA not available), in favour of UXP. Please note: the two are not compatible with each other.
I have a series of videos available on YouTube for free about UXP, if you w
...Copy link to clipboard
Copied
It depends on whether you want to use Document Object Model- or Action Manager-code.
This pdf should cover the DOM-methods (for document in the case of saving as, for application in the case of opening a file).
photoshop-javascript-ref-2020.pdfGitHubhttps://github.com › blob › master › Documentation
Copy link to clipboard
Copied
Thanks alot! Let me try it out.
Copy link to clipboard
Copied
@Joseph25509234xr72 – When first startng scripting (and even today), I often struggled with the official docs, I found them useful to dissect example code, but had major issues using them to write code from scratch.
Searching this forum for keywords such as:
or
Copy link to clipboard
Copied
I have really been struggling with this. The official docs usually just give the format, but not many practical examples.
I got frustrated to the point I decided to just post here in the community for help.
Thanks alot
Copy link to clipboard
Copied
@Stephen_A_Marsh Is there another resource I can use to learn adobe scripting other than the official documents? e.g. books, online courses, youtube tutorials?
Copy link to clipboard
Copied
As my previous post advised, searching the Adobe Photoshop forum for a scripting keyword will deliver a wealth of working code examples.
The other main scripting site with code to learn from is:
As for books, legacy ExtendScript and the new UXP is exhaustively covered by:
Copy link to clipboard
Copied
Thanks Stephen, let me give @Joseph25509234xr72 some extra-context.
The scripting code in the replies above is ExtendScript (an Adobe-proprietary flavour of JS based on a very old language specification). Since late 2020, Photoshop has been transitioning to UXP, which uses modern JavaScript. ExtendScript is going to be faded out (ETA not available), in favour of UXP. Please note: the two are not compatible with each other.
I have a series of videos available on YouTube for free about UXP, if you want to get started. For a more curated learning path, in late 2023 I've published a 326-page book on the subject; Marc Autret (a fine InDesign developer) has written a detailed, independent review which you can read here if you're interested.
Adobe is generally good with Reference documentation, not so much with narrative content; I'm trying to fill the gap.
Copy link to clipboard
Copied
Hi @Davide_Barranca. Thank you so much for that extra-context. I had only heard very little about UXP from one Youtube video I watched.
Thanks for all the links to your content. Let me check them out. I need that narrative content, lol!
Copy link to clipboard
Copied
@Stephen_A_Marsh Thanks so much for this!
Copy link to clipboard
Copied
You're welcome @Joseph25509234xr72
I found it hard to learn without a specific goal.
Start small, pick one simple thing that you can do via the GUI or an action and then learn how to do it via scripting.
It could be opening or saving a file in another format. It could be adding, removing or renaming a layer or running a filter. It doesn't really matter! Just do one thing. Knowledge and experience will build upon itself. Before you know it, you will be scripting two things, then more!
Copy link to clipboard
Copied
Thanks so much for that advice. That is exactly what I plan to do!
I work with Photoshop everyday because of the work I do. So part of my plan is to begin by automating some of the repetitive tasks in my workflow.
I just find it so thrilling that you can control so much via scripts. I want to learn it well and even take it to the next levels: extensions, plugins etc.