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

Extendscript way to "preview" changes to a photoshop document?

Community Beginner ,
Aug 02, 2018 Aug 02, 2018

Copy link to clipboard

Copied

I'm currently trying to make a photoshop panel that will let you preview different changes to a document, so that you can visually compare them to see which you like best.  I've been able to create a basic CEP panel and achieve simple effects with Extendscript on my active document, and I can also save and load versions of the current document in my panel folder.

What I'm struggling with now is how to "duplicate" in memory the open document, apply a change to it, and then either display it or save it off to a different file.  I don't want to alter the app.activeDocument.

For instance, say I have the following in my JSX:

var sanitizedFilePath = File(extensionPath + "/cache/lighter_shadows.jpg");

var exportOptions = new ExportOptionsSaveForWeb();

exportOptions.format = SaveDocumentType.JPEG;

app.activeDocument.artLayers[0].adjustColorBalance([80,80,80], [100,100,100],[100,100,100],false);

app.activeDocument.exportDocument(sanitizedFilePath, ExportType.SAVEFORWEB, exportOptions);

This will correctly lighten the image and save a copy of it to my temp folder, which I can then load, but it will of course change the currently open document as well.  Instead, I'd like to do something like:

var lightShadows = new Document(app.activeDocument);               //copy the active image to a new, undisplayed document

lightShadows.artLayers[0].adjustColorBalance([80,80,80], [100,100,100],[100,100,100],false);   //apply some minor visual change

lightShadows.exportDocument(sanitizedFilePath, ExportType.SAVEFORWEB, exportOptions);    //save it to a temp file

I believe using app.documents.add won't work, because it will always just create a newly opened empty document, whereas I don't want to "open" a new document in photoshop, I just want to work with one in code and then display it in my panel.  I could perhaps make changes, export the file with those changes, then undo the changes, but it seems like it would be rather disruptive for a user. 

Does anyone have any suggestions to help with this?  Is there any good process for "previewing" changes to an image in a photoshop 2018 CEP panel?

Thank you for any advice!

Views

614

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

People's Champ , Aug 06, 2018 Aug 06, 2018

I think you could create a copy of the source file and edit it but I don't think you could have it "hidden" from user's eyes.

You could always try to mimic ps filters in the HTML area (canvas ?) but chances are great that it's seriously far from faithful.

C++ might be the way to go here.

Votes

Translate

Translate
Guru ,
Aug 05, 2018 Aug 05, 2018

Copy link to clipboard

Copied

While your question is very much CEP as you havn't got an answer here yet have a go in the Photoshop scripting forum, and post an answer here if you get one.

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
People's Champ ,
Aug 06, 2018 Aug 06, 2018

Copy link to clipboard

Copied

LATEST

I think you could create a copy of the source file and edit it but I don't think you could have it "hidden" from user's eyes.

You could always try to mimic ps filters in the HTML area (canvas ?) but chances are great that it's seriously far from faithful.

C++ might be the way to go here.

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