Created
April 15, 2013 12:22
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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