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

Photoshop Script for Saving Image

Engaged ,
Aug 26, 2017 Aug 26, 2017

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.

-uS9S-53T6amyrRbhsU-Ig.png

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.

TOPICS
Actions and scripting

Views

5.4K

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

Community Expert , Aug 26, 2017 Aug 26, 2017

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

...

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 26, 2017 Aug 26, 2017

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)

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 ,
Aug 26, 2017 Aug 26, 2017

Copy link to clipboard

Copied

Thanks, that gave me a really good start.  I appreciate it.

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
Advocate ,
Aug 27, 2017 Aug 27, 2017

Copy link to clipboard

Copied

If I want to save on my desktop

In the resize folder

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
Advocate ,
Aug 27, 2017 Aug 27, 2017

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" );

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
Advocate ,
Aug 27, 2017 Aug 27, 2017

Copy link to clipboard

Copied

LATEST

Could you make sure that it saves directly without opening the save as named window?

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