Photoshop script help - canvas resizing

Calling all scripting gurus!!!

If anyone can help, I would truly appreciate it. I would like to be able to run a script that looks at the width and height of an image and then squares the document based on which ever is larger (width or height). Some of my images are larger in width, while others are larger in height.

Thanks in advance,
Jason

The dictionary says document width and height are read only so you cannot set them.
You can change the size of the image just not the document.

Regards,

Craig

This is doable…I actually do it myself currently. You need to be aware of the resolution as well.

set w to width of DocRef
set h to height of DocRef
set r to resolution of DocRef
resize image DocRef width newSize resolution 72
resize canvas DocRef height newSize anchor position middle center

Nice. I should have known not to trust the dictionary!

Thanks for your post.

Craig

So, are these two scripts that I can have Photoshop call upon via an Action?

No, these are applescript scripts…the idea would be that you would script the entire process. These would be bits you would use in your script.

Oh. I was hoping that there would be a way to do it as a Photoshop script. Dang.

No, you can’t do the type of logic you’re looking for within an action. There is no way to test for a height and width to check which dimension is larger.