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

How to open a file in Photoshop with javascript

Contributor ,
Nov 13, 2015 Nov 13, 2015

Copy link to clipboard

Copied

HI!

I want to open a file/image with a button click in an extension, in photoshop >> javascript. 

Possibly with relative path  to the extension file (it have to work on several different computers)

I tried several scripts:

===================================================================================

function somename(){


#target photoshop

var fileRef = "C:\\Users\\Username\\Desktop\\scripting\\image.png"     // I tried several differnet syntay about the path >> / \  \\ etc. etc.

var doc = open(fileRef);

}

================  OR  ==================================================================

function somename2(){


#target photoshop

var fileRef = new File( ~/desktop/scripting/image.png )     // I tried several differnet syntay about the path >> / \  \\ etc. etc.

app.open(fileRef)

}

======================================================

I know these paths are absolute but >> None of them had work so far


Any ideas?


ps: im new to this >> please be specific or provide some example 🙂  thanks!

TOPICS
Actions and scripting

Views

40.4K

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

Contributor , Nov 15, 2015 Nov 15, 2015

okay a little update!
Thanks Davide!

this works >> just i was a little to beginner to correctly interpret Davide answer.

So i put these code to the main.js file inside the JS folder:

(function () {

    'use strict';

    var csInterface = new CSInterface(); 

    function init() {

             

        themeManager.init();

             

        $("#something_1").click(function () {

  var csInterface = new CSInterface();

  var extensionPath = csInterface.getSystemPath(SystemPath.EXTENSION);

  var

...

Votes

Translate

Translate
Adobe
New Here ,
Oct 04, 2017 Oct 04, 2017

Copy link to clipboard

Copied

Capture.JPGddd.JPG

Auto Fill Frame ..So I am tired Please Slove this problem

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 ,
Oct 05, 2017 Oct 05, 2017

Copy link to clipboard

Copied

LATEST

Thanks for your help, I'm going to move this question into a new thread.

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