////////////////////////////////////////////////////////////////////// // savePSD and TGA | 3/20/2009 // // by Chris "Funky Bunnies" Whitaker ============// //==================================================================// // Description: // //------------------------------------------------------------------// // Saves psd wherever it is and a TGA one level up in directory // //==================================================================// //------------------------------------------------------------------// // Install: // //------------------------------------------------------------------// // - First drop the .jsx file(s) into: // // Program Files/Adobe/Photoshop/Presets/Scripts // // - Then open up Photoshop, otherwise it won't be there // // - Access the script through File->Scripts->savePSD and TGA // //------------------------------------------------------------------// // Hotkeys: // //------------------------------------------------------------------// // - Edit->Keyboard Shortcuts->Application Menus->File->etc... // // - you can use one of the F-buttons // // - hotkey assignment is limited in photoshop // ////////////////////////////////////////////////////////////////////// #target photoshop app.bringToFront(); main(); function main() { if (app.documents.length <= 0) { alert("There are no documents open!", "Aborted TGA export"); return; } // if at least one document exists, then proceed else { var activeDoc = app.activeDocument; var tgaPath; var psdPath; var initDlgDisplay = app.displayDialogs; //if name is in document name... try { tgaPath = (activeDoc.path.parent + "/" + activeDoc.name.substring(0, (activeDoc.name.length-3) ) +"tga"); psdPath = (activeDoc.path + "/" + activeDoc.name); } catch(err) { alert("You have not yet saved the document!", "Aborted TGA export", true); return;} if(activeDoc.channels.length >3) TargaSaveOptions.resolution = TargaBitsPerPixels.THIRTYTWO; else TargaSaveOptions.resolution = TargaBitsPerPixels.TWENTYFOUR; var width = activeDoc.width.as("px") var height = activeDoc.height.as("px") if (width & (width-1) || height & (height-1)) if ( !(confirm("Continue anyway?",true, "Warning: Image is not a power of 2!")) ) return; //Okay to default to always alpha channels because bits will determine if alpha saved or not TargaSaveOptions.alphaChannels = true; TargaSaveOptions.rleCompression=false //turn off dialogs real quick so the damn thing doesn't pop up when saving app.displayDialogs = DialogModes.NO; activeDoc.saveAs(new File(tgaPath), TargaSaveOptions, false, Extension.NONE); activeDoc.saveAs(new File(psdPath)); app.displayDialogs = initDlgDisplay; } }