Skip to content

Instantly share code, notes, and snippets.

@Arahnoid
Forked from kikmedia/psd2png.js
Last active April 21, 2019 22:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Arahnoid/5bf3dd9e7c4fc4597501 to your computer and use it in GitHub Desktop.
Save Arahnoid/5bf3dd9e7c4fc4597501 to your computer and use it in GitHub Desktop.
[PSD to PNG] 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. #Photoshop
#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