Skip to content

Instantly share code, notes, and snippets.

@kikmedia
Created April 15, 2013 12:22
Show Gist options
  • Save kikmedia/5387665 to your computer and use it in GitHub Desktop.
Save kikmedia/5387665 to your computer and use it in GitHub Desktop.
Dead simple javascript, providing a basic Photoshop action for exporting PSD files as PNG. Just launch it on your desktop. I think, this one is Windows only.
#target "photoshop"
var outputWidth = 1024;
var inputFolder = Folder.selectDialog("Input folder");
var outputFolder = Folder.selectDialog("Output folder");
if (inputFolder != null && outputFolder != null) {
var files = inputFolder.getFiles("*.psd");
for (var i = 0; i < files.length; i++) {
var file = files[i];
var doc = app.open(file);
if (doc.width > outputWidth) {
var height = (doc.height / doc.width) * outputWidth;
doc.resizeImage(outputWidth + "px", height + "px");
}
var options = new ExportOptionsSaveForWeb();
options.format = SaveDocumentType.PNG;
options.PNG8 = false;
doc.exportDocument(outputFolder, ExportType.SAVEFORWEB, options);
doc.close(SaveOptions.DONOTSAVECHANGES);
$.writeln('File ' + (i + 1) + ' of ' + files.length + ' processed');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment