Tuesday, July 19, 2016

photoshop scripting - When saving as a PSD, have a PNG also saved automatically


On Photoshop CS5, I had it set up so that whenever I saved a .psd, whether it were through cmd-s or the file menu, it would also save a file as a .png with the same name.


I upgraded to CS6 and now I have no idea how to recreate this. Sadly, or stupidly, I uninstalled CS5 so I can't attempt to troubleshoot that way.


Does anyone know how to do this? I don't want to have to run an action every time I want to save a psd as a png, I want it to happen automatically, every time I save.


I appreciate all and any help here.



Thank you, Jacob



Answer



You can create your own script if you want, here's a simple one:


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);
}



  • To use this go to File > Scripts > Scripts Event Manager

  • Tick "Enable Events to Run Scripts/Actions"

  • Select "Save Document" from the Photoshop Event dropdown

  • In the next dropdown box select your new script and click add.


Now every time you do a save, the script will check if you are saving it as a PSD, if it is, it will save a PNG with the same name to the same location.


Note: this will overwrite an existing PNG if there is already one in the save location.


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...