PhotoshopForums.com Home
Navigate Contact FAQ Search Members
Script to save as a PNG automatically after save (Ctrl + S)
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation
 See a User Guidelines violation? Please contact us.
Author Message

Adam_C

Joined: 18 Jun 2010
Posts: 4



PostPosted: Sat Oct 16, 2010 1:23 pm    Post subject: Script to save as a PNG automatically after save (Ctrl + S) Reply with quote

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 :)
View user's profile Send private message Visit poster's website

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Sun Oct 17, 2010 7:45 am    Post subject: Reply with quote

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.
View user's profile Send private message

Adam_C

Joined: 18 Jun 2010
Posts: 4



PostPosted: Sun Oct 17, 2010 8:25 am    Post subject: Reply with quote

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 :)
View user's profile Send private message Visit poster's website

thehermit

Joined: 05 Mar 2003
Posts: 3987
Location: Cheltenham, UK


PostPosted: Sun Oct 17, 2010 10:20 am    Post subject: Reply with quote

Nice work Paul, you lil code monkey;)
_________________
If life serves you lemons, make lemonade!
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Contact - User Guidelines >

Copyright © 2003-2016. PhotoshopForums.com, iFroggy Network. All Rights Reserved.
Powered by phpBB © phpBB Group. phpBB SEO. Privacy Policy.
We are in no way affiliated with Adobe. Photoshop, Adobe and related marks are registered trademarks of Adobe.
PhotoshopForums.com