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

Save for Web Export

New Here ,
Aug 07, 2008 Aug 07, 2008

Copy link to clipboard

Copied

I am trying to use the save for web export option to save out a file of type JPEG.

I have gotten the code working fine if it saved out with the default file type of .gif, but I cannot get it to work with .jpg.

set theExportOptions to {class:save for web export options, interlaced:true, quality:30}
tell current document
export in (theLocation as text) as save for web with options theExportOptions
end tell

These are the pertinent lines from my code, so if anybody can tell me how to save the file as type JPEG so that it is a scripted version of Photoshop's save for web feature, that would great.

I am also using Photoshop CS2 v9.02 if that helps.
TOPICS
Actions and scripting

Views

406

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
Adobe
Valorous Hero ,
Aug 07, 2008 Aug 07, 2008

Copy link to clipboard

Copied



function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

sfwOptions.format = SaveDocumentType.JPEG;

sfwOptions.includeProfile = false;

sfwOptions.interlaced = 0;

sfwOptions.optimized = true;

sfwOptions.quality = jpegQuality; //0-100

activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

}

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
New Here ,
Aug 16, 2008 Aug 16, 2008

Copy link to clipboard

Copied

Hi Paul,

Thanks for the script, I got it working but I can't find the "image size" property in the javascript reference for ExportOptionsSaveForWeb, which is an available option if I go File -> Save for web & devices -> image size

How would you add that property to the above script? Thank you.

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
Valorous Hero ,
Aug 16, 2008 Aug 16, 2008

Copy link to clipboard

Copied

LATEST
You would have to code that seperate eg:





FitImage(1000,500);



function FitImage( inWidth, inHeight ) {

if ( inWidth == undefined || inHeight == undefined ) {

alert( "FitImage requires both Width & Height!");

return 100;

}

var desc = new ActionDescriptor();

var unitPixels = charIDToTypeID( '#Pxl' );

desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );

desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );

var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );

executeAction( runtimeEventID, desc, DialogModes.NO );

}

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