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

How to display PS 'SaveAs' option dialogs, but not file save dialog?

Participant ,
Mar 23, 2018 Mar 23, 2018

In a JS script we want to display the appropriate  Photoshop image options dialogs for JPEGS, PNGS, TIFFs or PSDs for a Save or SaveAs action to the user - but not show the actual file save dialog - as we need to limit where the file is actually saved to a particular working folder.

Is this possible ?

Thanks.

TOPICS
Actions and scripting
3.3K
Translate
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 , Mar 25, 2018 Mar 25, 2018

Try this

// example

save_as_eps(activeDocument);

///////////////////////////////////////////////////////////////////////////////

function save_as_jpg(doc)

    {

    try {

        var d = new ActionDescriptor();

        var d1 = new ActionDescriptor();

        d1.putInteger(stringIDToTypeID("extendedQuality"), 10);

        d1.putInteger(stringIDToTypeID("scans"), 3);

        d1.putEnumerated(stringIDToTypeID("matteColor"), stringIDToTypeID("matteColor"), stringIDToTypeID("none"));

        d.putObject(stringI

...
Translate
Adobe
Contributor ,
Mar 23, 2018 Mar 23, 2018

#target photoshop;

saveAs();

function saveAs(){

try{

var sa = new ActionDescriptor()

executeAction( charIDToTypeID( "save" ), sa, DialogModes.ALL );

}catch(e){}

};

Translate
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
Participant ,
Mar 24, 2018 Mar 24, 2018

No.

I want to only open the Image Options dialogs we see at save and catch its results. Your example  opens a File Save dialog which I do not want.

Thanks.

Translate
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 ,
Mar 24, 2018 Mar 24, 2018

var d = new ActionDescriptor();

d.putPath(stringIDToTypeID("in"), new File(activeDocument.path));

d.putBoolean(stringIDToTypeID("forceFormatOptions"), true);

executeAction(stringIDToTypeID("save"), d, DialogModes.NO);

Translate
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
Participant ,
Mar 25, 2018 Mar 25, 2018

Nope. This script did save, but did not display the image options dialog with PS CC 2018.

I really just want to open an options dialog by file type (TIFF, JPEG, etc) and catch  its chosen attributes, and then do the save .

Any ideas?

Thanks for your help.

pete

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

Everything works great on CS6 and CC2018 (19.1.2).
When saving, only options for JPG, PNG, etc. are displayed, depending on the type. The "Save As" window is not displayed.

If this is not what you need, explain to the stupid using simple words and screenshots.

Translate
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
Participant ,
Mar 25, 2018 Mar 25, 2018

Well that sounds promising. I open a doc in photoshop, made an edit, then ran the script you sent.

Is that how it worked for you?

On a Mac.

p

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

I have windows.

At me only such window and similar for other formats pops out.

vvvv.png

In order for the file to actually be saved it must be flattened

And what's going on with you?

Translate
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
Participant ,
Mar 25, 2018 Mar 25, 2018

I got to work with JPEG as you say, I had been using a .psd.

Not sure now I think about it a PSD has options other than Layers.'

But will this work for a save as - do I need to edit script for that?

p

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

mmm.png

For PSD format, if you click "Do not show."
you will have to reset preferences

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

Explain in detail what formats you want to save. I think for Save As it works too. Now I'll try. You did not ask

Translate
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
Participant ,
Mar 25, 2018 Mar 25, 2018

This is part of a working client to an content manager. I had written my own image option dialogs - but customer wants them to be PS native image option dialogs.  So..

they are allowed to use: PSD, EPS, JPG, TIFF, and PNG. They might stay with same type or change from one in the list of types to another in the list.

Thanks,

p

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

Try this

// example

save_as_eps(activeDocument);

///////////////////////////////////////////////////////////////////////////////

function save_as_jpg(doc)

    {

    try {

        var d = new ActionDescriptor();

        var d1 = new ActionDescriptor();

        d1.putInteger(stringIDToTypeID("extendedQuality"), 10);

        d1.putInteger(stringIDToTypeID("scans"), 3);

        d1.putEnumerated(stringIDToTypeID("matteColor"), stringIDToTypeID("matteColor"), stringIDToTypeID("none"));

        d.putObject(stringIDToTypeID("as"), stringIDToTypeID("JPEG"), d1);

        d.putPath(stringIDToTypeID("in"), new File(doc.path));

        d.putInteger(stringIDToTypeID("documentID"), doc.id);

        d.putBoolean(stringIDToTypeID("copy"), true);

        d.putEnumerated(stringIDToTypeID("saveStage"), stringIDToTypeID("saveStageType"), stringIDToTypeID("saveBegin"));

        d.putBoolean(stringIDToTypeID("forceFormatOptions"), true); 

        executeAction(stringIDToTypeID("save"), d, DialogModes.NO);

        }

    catch (e) { alert(e); }

    }

///////////////////////////////////////////////////////////////////////////////

function save_as_tif(doc)

    {

    try {

        var d = new ActionDescriptor();

        var d1 = new ActionDescriptor();

        d1.putEnumerated(stringIDToTypeID("byteOrder"), stringIDToTypeID("platform"), stringIDToTypeID("IBMPC"));

        d1.putEnumerated(stringIDToTypeID("layerCompression"), stringIDToTypeID("encoding"), stringIDToTypeID("RLE"));

        d.putObject(stringIDToTypeID("as"), stringIDToTypeID("TIFF"), d1);

        d.putPath(stringIDToTypeID("in"), new File(doc.path));

        d.putInteger(stringIDToTypeID("documentID"), doc.id);

        d.putEnumerated(stringIDToTypeID("saveStage"), stringIDToTypeID("saveStageType"), stringIDToTypeID("saveBegin"));

        d.putBoolean(stringIDToTypeID("forceFormatOptions"), true); 

        executeAction(stringIDToTypeID("save"), d, DialogModes.NO);

        }

    catch (e) { alert(e); }

    }

///////////////////////////////////////////////////////////////////////////////

function save_as_png(doc)

    {

    try {

        var d = new ActionDescriptor();

        var d1 = new ActionDescriptor();

        d1.putEnumerated(stringIDToTypeID("PNGInterlaceType"), stringIDToTypeID("PNGInterlaceType"), stringIDToTypeID("PNGInterlaceNone"));

        d1.putEnumerated(stringIDToTypeID("PNGFilter"), stringIDToTypeID("PNGFilter"), stringIDToTypeID("PNGFilterAdaptive"));

        d1.putInteger(stringIDToTypeID("compression"), 9);

        d.putObject(stringIDToTypeID("as"), stringIDToTypeID("PNGFormat"), d1);

        d.putPath(stringIDToTypeID("in"), new File("doc.path"));

        d.putInteger(stringIDToTypeID("documentID"), doc.id);

        d.putBoolean(stringIDToTypeID("copy"), true);

        d.putEnumerated(stringIDToTypeID("saveStage"), stringIDToTypeID("saveStageType"), stringIDToTypeID("saveBegin"));

        d.putBoolean(stringIDToTypeID("forceFormatOptions"), true); 

        executeAction(stringIDToTypeID("save"), d, DialogModes.NO);

        }

    catch (e) { alert(e); }

    }

///////////////////////////////////////////////////////////////////////////////

function save_as_eps(doc)

    {

    try {

        var d = new ActionDescriptor();

        var d1 = new ActionDescriptor();

        d1.putEnumerated(stringIDToTypeID("preview"), stringIDToTypeID("EPSPreview"), stringIDToTypeID("TIFF"));

        d1.putEnumerated(stringIDToTypeID("depth"), stringIDToTypeID("depth"), stringIDToTypeID("1BitPerPixel"));

        d1.putEnumerated(stringIDToTypeID("encoding"), stringIDToTypeID("encoding"), stringIDToTypeID("ASCII85"));

        d1.putBoolean(stringIDToTypeID("halftoneScreen"), false);

        d1.putBoolean(stringIDToTypeID("transferFunction"), false);

        d1.putBoolean(stringIDToTypeID("colorManagement"), false);

        d1.putBoolean(stringIDToTypeID("interfaceIconFrameDimmed"), false);

        d.putObject(stringIDToTypeID("as"), stringIDToTypeID("photoshopEPSFormat"), d1);

        d.putPath(stringIDToTypeID("in"), new File(doc.path));

        d.putInteger(stringIDToTypeID("documentID"), doc.id);

        d.putBoolean(stringIDToTypeID("copy"), true);

        d.putEnumerated(stringIDToTypeID("saveStage"), stringIDToTypeID("saveStageType"), stringIDToTypeID("saveSucceeded"));

        d.putBoolean(stringIDToTypeID("forceFormatOptions"), true); 

        executeAction(stringIDToTypeID("save"), d, DialogModes.NO);

        }

    catch (e) { alert(e); }

    }

///////////////////////////////////////////////////////////////////////////////

function save_as_psd(doc)

    {

    try {

        var d = new ActionDescriptor();

        var d1 = new ActionDescriptor();

        d1.putBoolean(stringIDToTypeID("maximizeCompatibility"), false);

        d.putObject(stringIDToTypeID("as"), stringIDToTypeID("photoshop35Format"), d1);

        d.putPath(stringIDToTypeID("in"), new File(doc.path));

        d.putInteger(stringIDToTypeID("documentID"), doc.id);

        d.putEnumerated(stringIDToTypeID("saveStage"), stringIDToTypeID("saveStageType"), stringIDToTypeID("saveSucceeded"));

        d.putBoolean(stringIDToTypeID("forceFormatOptions"), true); 

        executeAction(stringIDToTypeID("save"), d, DialogModes.NO);

        }

    catch (e) { alert(e); }

    }

Translate
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
Participant ,
Mar 25, 2018 Mar 25, 2018

That's awesome!  Thanks so much.

pete

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

remove strings

d.putEnumerated(stringIDToTypeID("saveStage")...

from thr code

this is garbage

Translate
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
Guide ,
Mar 25, 2018 Mar 25, 2018

There is a typo in save_as_png()

d.putPath(stringIDToTypeID("in"), new File("doc.path"));

doc.path has quotes around it.

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

Yeah!

By the way the code is received by a script from this topicScript Events Listener

Translate
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
Participant ,
Mar 25, 2018 Mar 25, 2018

Got it. Thanks again.

Translate
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 ,
Mar 25, 2018 Mar 25, 2018

In short. I found that Photoshop allows you to save only an active document. Even in the DOM version.

Therefore, the code line

d.putInteger(stringIDToTypeID("documentID"), doc.id);

is also a garbage and does not affect anything.

And the first line with each function should be put

app.activeDocument = doc;

Translate
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
Participant ,
Mar 27, 2018 Mar 27, 2018

Here's a wrinkle - sometimes when using this script to save images - PS CC 2018 saves as a copy - so 'my image.jpg' becomes 'myinmage copy.jpg'. Do you know how to prevent this from happening?

The options stuff looking good.

Translate
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
Advocate ,
Mar 27, 2018 Mar 27, 2018

Ever tried to flatten your image before saving as jpg?

Translate
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
Participant ,
Mar 27, 2018 Mar 27, 2018
LATEST

Whoops - Never mind - I found this ( d.putBoolean(stringIDToTypeID("copy"), true); ) in several of the option type routines and changed it to be 'false'.

Translate
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