Determing Photoshop Width vs Height

Presently I have to use two Quickeys that hold two separate scripts that are practically identical.

For instance the below script is targeting the “Square” action form a Photoshop action set.

I could avoid two Quickeys if the following was possible:

Is there any way to tell the script if the active document’s width is equal to or less than 125% of the active document’s height, then do action “Square” from “StreamlineTemplate.atn”
if the active document’s width is equal to or greater than 125% of the height then do action “Wide” from “StreamlineTemplate.atn”

I just don’t know how to tell the script to find the image dimensions and perform such math?

Can anyone help me?

-jeff

tell application "Adobe Photoshop CS"
	activate
	do action "Square" from "StreamlineTemplate.atn"
	tell application "System Events" to keystroke "," using {command down}
end tell

This works for me in PS7, Jeff - so you might try an adaptation. (Many commands/functions are the same or similar, so just try changing the app name to start with.)

tell application "Adobe Photoshop 7.0"
	tell current document
		width ≤ height * 1.25
	end tell
end tell

Kai,
Your code will get the values, but I can’t seem to make the script differentiate and perform following actions based on either of the two sizes.

Can you help me out. Although you already have helped tremendously.

I think this can be done.

-jeff

tell application "Adobe Photoshop CS"
	tell current document
		try
			width ≤ height * 1.25
			do action "Wide" from "StreamlineTemplate.atn"
			tell application "System Events" to keystroke "," using {command down}
		end try
		try
			width ≥ height * 1.25
			do action "Square" from "StreamlineTemplate.atn"
			tell application "System Events" to keystroke "," using {command down}
		end try
	end tell
end tell

Jeff,

You may want to search the forms or browse other posts and look for if / then statements. It’s a core concept of programming and would help you tremendously.

-N

Sorry Jeff, I didn’t realise that you were looking for a pointer on the conditional side of things, too. No worries.

Try something like this:

tell application "Adobe Photoshop CS" to tell current document
	if width < height * 1.25 then
		do action "Square" from "StreamlineTemplate.atn"
	else
		do action "Wide" from "StreamlineTemplate.atn"
	end if
end tell
tell application "System Events" to keystroke "," using {command down}

(Incidentally, since only one condition or the other can include equivalence, the above will go for “Wide” if width = height * 1.25 exactly. I’ll leave the final decision on that one to you…) :slight_smile:

No problem Kai,
Thank you for helping. I just was about to post what I just created, which seems to work. And then I saw your newest post.
FWIW, this is what I came up with that seems to work. (But I see I could have eliminated a line)
I do need to learn more fundamentals. Every time I set out to learn, I get bombarded with other tasks that take priority at work and home :frowning:
Thank you so much, I am going to try your script right now.

tell application "Adobe Photoshop CS"
	tell current document
		try
			if width ≤ height * 1.25 then
				do action "Square" from "StreamlineTemplate.atn"
				
			else if width ≥ height * 1.25 then
				do action "Wide" from "StreamlineTemplate.atn"
			end if
			tell application "System Events" to keystroke "," using {command down}
		end try
	end tell
end tell

Kai,
Thanks again,
Your script is PERFECT!!!

Yeah - I know the feeling, Jeff. Life somehow seems to have a habit of getting in the way… :wink:

Delighted to hear the suggestion worked out. :smiley: