Copy link to clipboard
Copied
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.
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
Copy link to clipboard
Copied
#target photoshop;
saveAs();
function saveAs(){
try{
var sa = new ActionDescriptor()
executeAction( charIDToTypeID( "save" ), sa, DialogModes.ALL );
}catch(e){}
};
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
var d = new ActionDescriptor();
d.putPath(stringIDToTypeID("in"), new File(activeDocument.path));
d.putBoolean(stringIDToTypeID("forceFormatOptions"), true);
executeAction(stringIDToTypeID("save"), d, DialogModes.NO);
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I have windows.
At me only such window and similar for other formats pops out.
In order for the file to actually be saved it must be flattened
And what's going on with you?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
For PSD format, if you click "Do not show."
you will have to reset preferences
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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); }
}
Copy link to clipboard
Copied
That's awesome! Thanks so much.
pete
Copy link to clipboard
Copied
remove strings
d.putEnumerated(stringIDToTypeID("saveStage")...
from thr code
this is garbage
Copy link to clipboard
Copied
There is a typo in save_as_png()
d.putPath(stringIDToTypeID("in"), new File("doc.path"));
doc.path has quotes around it.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Got it. Thanks again.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Ever tried to flatten your image before saving as jpg?
Copy link to clipboard
Copied
Whoops - Never mind - I found this ( d.putBoolean(stringIDToTypeID("copy"), true); ) in several of the option type routines and changed it to be 'false'.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now