Copy link to clipboard
Copied
Suppose I want to create a photoshop script that will save the current document according to specifically-defined settings in the code itself. How might I go about doing this? For example, suppose I want this script to automatically save the current document as a .jpg file in such a way that my script can specify not only the file name, but also all of the parameters that would normally appear in the "JPEG Options" dialogue box.
I have no idea how I would access these properties within my script. Would somebody please be able to provide some sample code that would save the current document as well as link to a resource that would explain how to modify these types of parameters via the script code? Thank you.
Here's a snippet that has all the ways you can save a jpg. You can create a UI to set them or you can hard code them into your script. These all are not needed to specify, if you use the standard default options for saving jpgs.
...var saveFolder = new Folder('/c/Save Folder/'); //enter path for where you want the file saved
var fileName = 'My File';
var doc= activeDocument
var jpgOptions = new JPEGSaveOptions();
jpgOptions.quality = 8; //enter number or create a variable to set quality
jpgOptions.embedC
Copy link to clipboard
Copied
Here's a snippet that has all the ways you can save a jpg. You can create a UI to set them or you can hard code them into your script. These all are not needed to specify, if you use the standard default options for saving jpgs.
var saveFolder = new Folder('/c/Save Folder/'); //enter path for where you want the file saved
var fileName = 'My File';
var doc= activeDocument
var jpgOptions = new JPEGSaveOptions();
jpgOptions.quality = 8; //enter number or create a variable to set quality
jpgOptions.embedColorProfile = true;
jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
//other options///////////////////////////
//jpgOptions.formatOptions = FormatOptions.PROGRESSIVE;
//jpgOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
if(jpgOptions.formatOptions == FormatOptions.PROGRESSIVE){
jpgOptions.scans = 3}; //only used with Progressive
jpgOptions.matte = MatteType.NONE;
//jpgOptions.matte = MatteType.BACKGROUND;
//jpgOptions.matte = MatteType.BLACK;
//jpgOptions.matte = MatteType.FOREGROUND;
//jpgOptions.matte = MatteType.NETSCAPE;
//jpgOptions.matte = MatteType.SEMIGRAY;
//jpgOptions.matte = MatteType.WHITE;
doc.saveAs (new File(saveFolder +'/' + fileName + '.jpg'), jpgOptions)
Copy link to clipboard
Copied
Thanks, that gave me a really good start. I appreciate it.
Copy link to clipboard
Copied
If I want to save on my desktop
In the resize folder
Copy link to clipboard
Copied
To save on desktop, change first line of code to something like this:
var saveFolder = new Folder( File(Folder.desktop).fsName + "/my Image Folder" );
Copy link to clipboard
Copied
Could you make sure that it saves directly without opening the save as named window?