Square Canvas in Photoshop with Javascript

This script is really simple, but it can be really useful if you need to make a lot of images square instead of rectangle. You can run it from File > Scripts > Browse…, but since we are talking about using it for a lot of images, you would probably want to record a macro. Then you can use the macro as any regular Photoshop macro.

var w = app.activeDocument.width;
var h = app.activeDocument.height;

if (w > h) {
	app.activeDocument.resizeCanvas(w,w);
}
if (h > w) {
	app.activeDocument.resizeCanvas(h,h);
}