Skip to content

Instantly share code, notes, and snippets.

@Wardrop
Created August 14, 2011 01:06
Show Gist options
  • Save Wardrop/1144454 to your computer and use it in GitHub Desktop.
Save Wardrop/1144454 to your computer and use it in GitHub Desktop.
final_width = 400
final_height = 400
for (var i = 0; i < app.documents.length; i++) {
crop_width_by = 0
crop_height_by = 0
doc = app.documents[i]
app.activeDocument = doc
landscape = (doc.height < doc.width)
if (landscape == true) {
doc.resizeImage(undefined, final_height)
crop_width_by = (doc.width - final_width) / 2
} else {
doc.resizeImage(final_width)
crop_height_by = (doc.height - final_height) / 2
}
doc.crop([crop_width_by, crop_height_by, doc.width - crop_width_by, doc.height - crop_height_by])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment