Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It is possible to "save for web" by using ExportOptionsSaveForWeb. I have provided an example of its usage on my blog in a post titled Photoshop “save for web” JavaScript.
Copy link to clipboard
Copied
function SavePNG(savefile){
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.embedColorProfile = true;
pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
pngSaveOptions.matte = MatteType.NONE;
pngSaveOptions.quality = 1;
pngSaveOptions.PNG8 = false
pngSaveOptions.transparency = true;
doc.saveAs(savefile, pngSaveOptions, true, Extension.LOWERCASE);
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
var saveFile = decodeURI(selectedFolder);
saveFile= saveFile.substring((saveFile.lastIndexOf('/')+1));
saveFile = new File(selectedFolder+'/'+saveFile+'.png');
Copy link to clipboard
Copied
Copy link to clipboard
Copied
#target photoshop
/////////////////////////////////////////////////////////////////////////////////////////////////
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
//////////////////////////////////////////////////////////////////////////////////////////////////
selectedFolder = Folder.selectDialog( "Please select input folder");
var saveFile = decodeURI(selectedFolder).replace(selectedFolder.parent,'');
saveFile = new File(selectedFolder+saveFile+'.png');
var fileList = selectedFolder.getFiles();
for(var aFile = 0; aFile<fileList.length;aFile++){
var file = fileList[aFile];
if(file instanceof File && file.name.match(/\.png$/i)){
open(file);
////////////////////////////////////////Add Extra Boarder Stripe to maintain relative positon
var Width =activeDocument.width.value;
var Height =activeDocument.height.value;
activeDocument.resizeCanvas(Width+2, Height, AnchorPosition.MIDDLECENTER)
var Width =activeDocument.width.value;
var Height =activeDocument.height.value;
var fillColor = new SolidColor;
fillColor.rgb.hexValue = '000000';
activeDocument.selection.select([[0,0],[1,0],[1,Height],[0,Height]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColor, ColorBlendMode.NORMAL, 100, false );
activeDocument.selection.deselect();
activeDocument.selection.select([[(Width-1),0],[Width,0],[Width,Height],[(Width-1),Height]], SelectionType.REPLACE, 0, false);
activeDocument.selection.fill(fillColor, ColorBlendMode.NORMAL, 100, false );
activeDocument.selection.deselect();
////////////////////////////////////////
if(documents.length > 1){
////////////////////////////////////////Add to Frame Strip
activeDocument.selection.selectAll();
activeDocument.selection.copy();
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
activeDocument = documents[0];
app.activeDocument.resizeCanvas(app.activeDocument.width,app.activeDocument.height+Height, AnchorPosition.TOPCENTER);
activeDocument.paste();
activeDocument.selection.selectAll();
align('AdBt');
app.activeDocument.selection.deselect();
activeDocument.mergeVisibleLayers();
////////////////////////////////////////
}
}else{
continue;
}
}
////////////////////////////////////////Remove Extra Boarder Stripe and Save
var Width =activeDocument.width.value;
var Height =activeDocument.height.value;
activeDocument.resizeCanvas(Width-2, Height, AnchorPosition.MIDDLECENTER)
SavePNG(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
//////////////////////////////////////////////////////////////////////////////////////////////////
//CUSTOM FUNCTIONS
//////////////////////////////////////////////////////////////////////////////////////////////////
function align(method) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
};
function SavePNG(savefile){
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.embedColorProfile = true;
pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
pngSaveOptions.matte = MatteType.NONE;
pngSaveOptions.quality = 1;
pngSaveOptions.PNG8 = false
pngSaveOptions.transparency = true;
activeDocument.saveAs(savefile, pngSaveOptions, true, Extension.LOWERCASE);
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
var saveFile = decodeURI(selectedFolder).replace(selectedFolder.parent,'');
saveFile = new File(selectedFolder+saveFile+'.png');
var saveFile = decodeURI(selectedFolder);
saveFile= saveFile.substring((saveFile.lastIndexOf('/')+1));
saveFile = new File(selectedFolder+'/'+saveFile+'.png');
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
#target photoshop
/////////////////////////////////////////////////////////////////////////////////////////////////
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
//////////////////////////////////////////////////////////////////////////////////////////////////
imageFolder = Folder.selectDialog( "Please select input folder");
folderList=[];
if (imageFolder != null) processFolder(imageFolder);
folderList = ReturnUniqueSortedList(folderList)
for(var a = 0;a<folderList.length;a++){
var selectedFolder = folderList;
var saveFile = decodeURI(selectedFolder);
saveFile= saveFile.substring((saveFile.lastIndexOf('/'...
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now