Skip to main content
Participating Frequently
September 26, 2017
Answered

Open JPG/PNG image from html5 extension

  • September 26, 2017
  • 2 replies
  • 805 views

Hello Everyone,

Is there any way to open the JPG/PNG image from cc build.

I found a solution and implemented it in extension

app.open(File(filePath));

but it opens the file in photoshop and I want to get it open in OS image viewer app like: "Preview" for mac and "Image viewer" for Windows

This topic has been closed for replies.
Correct answer Davide_Barranca12040269

You can try (in the JSX) to create a file instance and then execute it, like:

var f = new File('~/Desktop/flower.jpg')

if (f.exists) { f.execute() }

This should trigger the default app that is set for each OS (Preview on Mac, and Image viewer on Windows), provided that the user hasn't changed his OS preferences.

Hope this helps!

Davide

2 replies

Davide_Barranca12040269
Legend
September 27, 2017

You can try (in the JSX) to create a file instance and then execute it, like:

var f = new File('~/Desktop/flower.jpg')

if (f.exists) { f.execute() }

This should trigger the default app that is set for each OS (Preview on Mac, and Image viewer on Windows), provided that the user hasn't changed his OS preferences.

Hope this helps!

Davide

Davide Barranca - PS developer and authorwww.ps-scripting.com
Participating Frequently
September 27, 2017

Thanks, this was the solution I was looking for.

Thanks a log.

JJMack
Community Expert
Community Expert
September 27, 2017

That can be unpredictable it could be Photoshop be the same as app.open(File(filePath));

JJMack
JJMack
Community Expert
Community Expert
September 26, 2017

You would need to execute a system command not use a photoshop command.

app.system('the correct Mac or the correct windows command and pass the filePath');

for example this would stop the scriptlistener writting the javascript log file on windows

app.system('Attrib +R "%USERPROFILE%\\Desktop\\ScriptingListenerJS.log" ');

JJMack