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

Open JPG/PNG image from html5 extension

Community Beginner ,
Sep 26, 2017 Sep 26, 2017

Copy link to clipboard

Copied

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

TOPICS
Actions and scripting

Views

590

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 , Sep 27, 2017 Sep 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

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 26, 2017 Sep 26, 2017

Copy link to clipboard

Copied

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

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 ,
Sep 27, 2017 Sep 27, 2017

Copy link to clipboard

Copied

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 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
Community Beginner ,
Sep 27, 2017 Sep 27, 2017

Copy link to clipboard

Copied

Thanks, this was the solution I was looking for.

Thanks a log.

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 ,
Sep 27, 2017 Sep 27, 2017

Copy link to clipboard

Copied

LATEST

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

JJMack

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