Created
May 1, 2015 23:58
-
-
Save vladimirlukyanov/fedcadac8872004e20ef to your computer and use it in GitHub Desktop.
Rectangular_to_square_js_photoshop.js
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
var inputFolder = Folder.selectDialog("Select a folder to process"); | |
var fileList = inputFolder.getFiles("*.jpg"); | |
for(var i=0; i<fileList.length; i++) { | |
var doc = open(fileList[i]); | |
if (doc.width !== doc.height) { // if document is not already square... | |
if (doc.width > doc.height) { // if width is greater... | |
doc.resizeCanvas(doc.width, doc.width) // use this value for both sides... | |
} else { // else use height for both sides... | |
doc.resizeCanvas(doc.height, doc.height) // so you always get a square. | |
} | |
} | |
doc.save(); | |
doc.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment