|
Author |
Message |
Adam_C
Joined: 18 Jun 2010
Posts: 4
|
Posted: Sat Oct 16, 2010 1:23 pm Post subject: Script to save as a PNG automatically after save (Ctrl + S) |
|
|
Hi,
Does anyone know where I can find a Script for PS CS5 to save my current PSD as a PNG file automatically when I save the PSD?
Thanks in advance guys |
|
|
|
|
Paul R
Joined: 06 Apr 2010
Posts: 57
|
Posted: Sun Oct 17, 2010 7:45 am Post subject: |
|
|
This should do the job...
Code: |
main();
function main(){
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
if(Ext.toLowerCase() != 'psd') return;
var Path = app.activeDocument.path;
var saveFile = File(Path + "/" + Name +".png");
if(saveFile.exists) saveFile.remove();
SavePNG(saveFile);
}
function SavePNG(saveFile){
pngSaveOptions = new PNGSaveOptions();
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
|
save the code as a fileName.jsx and place it into
application presets/scripts/Events Scripts Only folder
Now, in Photoshop
File - Scripts -Scripts Event Manager
Tick Enable Events to Run Scripts/Actions
Select Photoshop Event "Save Document"
In the next dropdown box select your new script and click add.
Now every time you do a save, the script will check if it is a "psd" document, if it is it will save a png with the same name to the same location. |
|
|
|
|
Adam_C
Joined: 18 Jun 2010
Posts: 4
|
Posted: Sun Oct 17, 2010 8:25 am Post subject: |
|
|
Paul R wrote: | This should do the job...
Code: |
main();
function main(){
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Ext = decodeURI(app.activeDocument.name).replace(/^.*\./,'');
if(Ext.toLowerCase() != 'psd') return;
var Path = app.activeDocument.path;
var saveFile = File(Path + "/" + Name +".png");
if(saveFile.exists) saveFile.remove();
SavePNG(saveFile);
}
function SavePNG(saveFile){
pngSaveOptions = new PNGSaveOptions();
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
|
save the code as a fileName.jsx and place it into
application presets/scripts/Events Scripts Only folder
Now, in Photoshop
File - Scripts -Scripts Event Manager
Tick Enable Events to Run Scripts/Actions
Select Photoshop Event "Save Document"
In the next dropdown box select your new script and click add.
Now every time you do a save, the script will check if it is a "psd" document, if it is it will save a png with the same name to the same location. |
Thanks very much! works perfectly |
|
|
|
|
thehermit
Joined: 05 Mar 2003
Posts: 3987
Location: Cheltenham, UK
|
Posted: Sun Oct 17, 2010 10:20 am Post subject: |
|
|
Nice work Paul, you lil code monkey;) _________________ If life serves you lemons, make lemonade! |
|
|
|
|
|