Moderators: Patrick, Mike Hale, xbytor, Larry Ligon, Andrew, PS-Moderators
#target photoshop
app.bringToFront();
function main(){
desc1 = new ActionDescriptor();
UUID = 'c80495b0-6d15-11e1-b0c4-0800200c9a66';
Prefs={};
try{
desc1 = app.getCustomOptions(UUID);
Prefs = eval(desc1.getString(0));
}catch(e){
//no setting call UI, open first doc, update custom options then return
if (!BridgeTalk.isRunning('bridge')){
alert("You have not selected any files in Bridge");
return;
}
Prefs.fileList = GetFilesFromBridge();
if(Prefs.fileList.length == 0){
alert("You have not selected any files in Bridge");
return;
}
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}
//ok settings exist
if(!documents.length){
//should not get here, documents closed not using this script
//open next image, update custom options and return
if(Prefs.fileList.length >0){
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}
}
//ok document is open
//resize, save documents, close, open next, update custom options
alert("your save code goes here");
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
if(Prefs.fileList.length >0){
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}else{
app.eraseCustomOptions(UUID);
alert("Batch complete");
}
}
main();
function GetFilesFromBridge() {
function script(){
var fL = app.document.selections;
var tF=[];
for(var a in fL){
if(fL[a].type =='file'){
tF.push(new File(encodeURI(fL[a].spec.fsName)));
}
}
return tF.toSource();
}
var fileList;
var bt = new BridgeTalk();
bt.target = "bridge";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.onResult = function( inBT ) { fileList = eval( inBT.body ); }
bt.onError = function( inBT ) { fileList = new Array(); }
bt.send(8);
bt.pump();
if ( undefined == fileList ) fileList = new Array();
return fileList;
} #target photoshop
app.bringToFront();
function main(){
desc1 = new ActionDescriptor();
UUID = 'c80495b0-6d15-11e1-b0c4-0800200c9a66';
Prefs={};
try{
desc1 = app.getCustomOptions(UUID);
Prefs = eval(desc1.getString(0));
}catch(e){
//no setting call UI, open first doc, update custom options then return
if (!BridgeTalk.isRunning('bridge')){
alert("You have not selected any files in Bridge");
return;
}
Prefs.fileList = GetFilesFromBridge();
if(Prefs.fileList.length == 0){
alert("You have not selected any files in Bridge");
return;
}
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}
//ok settings exist
if(!documents.length){
//should not get here, documents closed not using this script
//open next image, update custom options and return
if(Prefs.fileList.length >0){
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}
}
//ok document is open
//resize, save documents, close, open next, update custom options
alert("your save code goes here");
saveJPEG(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
if(Prefs.fileList.length >0){
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}else{
app.eraseCustomOptions(UUID);
alert("Batch complete");
}
}
main();
function GetFilesFromBridge() {
function script(){
var fL = app.document.selections;
var tF=[];
for(var a in fL){
if(fL[a].type =='file'){
tF.push(new File(encodeURI(fL[a].spec.fsName)));
}
}
return tF.toSource();
}
var fileList;
var bt = new BridgeTalk();
bt.target = "bridge";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.onResult = function( inBT ) { fileList = eval( inBT.body ); }
bt.onError = function( inBT ) { fileList = new Array(); }
bt.send(8);
bt.pump();
if ( undefined == fileList ) fileList = new Array();
return fileList;
}
function SaveJPEG(saveFile){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;12
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}#target photoshop
app.bringToFront();
function main(){
desc1 = new ActionDescriptor();
UUID = 'c80495b0-6d15-11e1-b0c4-0800200c9a66';
Prefs={};
try{
desc1 = app.getCustomOptions(UUID);
Prefs = eval(desc1.getString(0));
}catch(e){
//no setting call UI, open first doc, update custom options then return
if (!BridgeTalk.isRunning('bridge')){
alert("You have not selected any files in Bridge");
return;
}
Prefs.fileList = GetFilesFromBridge();
if(Prefs.fileList.length == 0){
alert("You have not selected any files in Bridge");
return;
}
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}
//ok settings exist
if(!documents.length){
//should not get here, documents closed not using this script
//open next image, update custom options and return
if(Prefs.fileList.length >0){
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}else{
app.eraseCustomOptions(UUID);
alert("Batch complete");
return;
}
}
//ok document is open
//resize, save documents, close, open next, update custom options
//create a folder to put the processed files
var doc = app.activeDocument;
var saveFile = '';
var outputFolder = Folder(doc.path + "/Processed");
if(!outputFolder.exists) outputFolder.create();
var Name = decodeURI(doc.name).replace(/\.[^\.]+$/, '');
Name = Name.replace(/_m$/i,'');
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var maxPixels = Math.max(doc.width,doc.height);
if(maxPixels > 5000){
FitImage( 5000, 5000 );
saveFile = File(outputFolder + "/" + Name + ".tif");
SaveTIFF(saveFile);
}else{
saveFile = File(outputFolder + "/" + Name + ".tif");
SaveTIFF(saveFile);
}
FitImage( 1050, 1050 );
saveFile = File(outputFolder + "/" + Name + "_pp.jpg");
SaveJPEG(saveFile, 12);
FitImage( 250, 250 );
saveFile = File(outputFolder + "/" + Name + ".jpg");
SaveJPEG(saveFile, 12);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.preferences.rulerUnits = startRulerUnits;
if(Prefs.fileList.length >0){
app.open(File(Prefs.fileList.shift()));
desc1.putString(0, Prefs.toSource());
app.putCustomOptions(UUID, desc1, true );
return;
}else{
app.eraseCustomOptions(UUID);
alert("Batch complete");
}
}
main();
function GetFilesFromBridge() {
function script(){
var fL = app.document.selections;
var tF=[];
for(var a in fL){
if(fL[a].type =='file'){
tF.push(new File(encodeURI(fL[a].spec.fsName)));
}
}
return tF.toSource();
}
var fileList;
var bt = new BridgeTalk();
bt.target = "bridge";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.onResult = function( inBT ) { fileList = eval( inBT.body ); }
bt.onError = function( inBT ) { fileList = new Array(); }
bt.send(8);
bt.pump();
if ( undefined == fileList ) fileList = new Array();
return fileList;
}
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 );
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
}var outputFolder = Folder(doc.path + "/Processed");
if(!outputFolder.exists) outputFolder.create();var outputFolder = Folder(doc.path);
UUID = 'c80495b0-6d15-11e1-b0c4-0800200c9a66';
app.eraseCustomOptions(UUID);UUID = 'c80495b0-6d15-11e1-b0c4-0800200c9a66';
app.eraseCustomOptions(UUID);app.eraseCustomOptions(UUID);
UUID = 'c80495b0-6d15-11e1-b0c4-0800200c9a66';
app.eraseCustomOptions(UUID);Users browsing this forum: No registered users and 0 guests