Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vladimirlukyanov/fedcadac8872004e20ef to your computer and use it in GitHub Desktop.
Save vladimirlukyanov/fedcadac8872004e20ef to your computer and use it in GitHub Desktop.
Rectangular_to_square_js_photoshop.js
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