• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

scripting for Photoshop (how to write Javascript code to "open" a file, and "save as")

Explorer ,
Aug 21, 2023 Aug 21, 2023

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.

TOPICS
Actions and scripting

Views

844

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jan 24, 2024 Jan 24, 2024

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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 21, 2023 Aug 21, 2023

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

Screenshot 2023-08-21 at 16.08.17.pngScreenshot 2023-08-21 at 16.08.45.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 22, 2023 Aug 22, 2023

Copy link to clipboard

Copied

Thanks alot! Let me try it out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 22, 2023 Aug 22, 2023

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:

 

.saveAs(

 

or

 

 
or
 
 
or
 
 
or
 
 
Will help you to find full working code examples which may help in addition to the docs.
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 25, 2023 Aug 25, 2023

Copy link to clipboard

Copied

@Stephen_A_Marsh 

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 23, 2024 Jan 23, 2024

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2024 Jan 23, 2024

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:


https://www.ps-scripts.com/

 

As for books, legacy ExtendScript and the new UXP is exhaustively covered by:

 

https://www.davidebarranca.com

https://www.ps-scripting.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 24, 2024 Jan 24, 2024

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. 

 

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 24, 2024 Jan 24, 2024

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! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

@Stephen_A_Marsh Thanks so much for this!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2024 Jan 24, 2024

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

LATEST

@Stephen_A_Marsh 

 

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines