Help required with AppleScript and Photoshop CS3

Bit of a tough one, and I’m not sure if it’s possible to do this.

For part of my job, I have to use a specific crop field to draw an area around photos of teeth, as well as 3 head shots for orthodontic patient records.
I’m trying to find a script that I can run with one hotkey, which does about 3 or 4 keystrokes all in one go.

When I draw the crop field around the area, if I then press cmd+s to save, it will ask if I want to crop (which I do), so I press return. Photoshop then opens the JPEG settings box, and since this is the same for every photo (quality set to 10), I press return again. Then I press cmd+w to close the window.

Alternatively if I just press cmd+w for the first step, it will ask me if I want to crop, and then if I want to save changes. One hotkey combo shorter than above.

I’m not sure if there’s a way to do this in applescript, but it doesn’t work with photoshop’s actions, as I can’t record an action while an area is selected by the crop tool.
If there’s a way to applescript it, it would make things a bit faster for me.
The final result I’m after would be to have this string of keystrokes assigned as one hotkey, but I don’t know how I could assign this within Photoshop, or with global hotkeys.

Thanks in advance.

Is the crop area a consistent size and placement? If so you might be able to automate the crop and save with an applescript, a drag and drop might work well for this.

You might be able to use a rectangular selection instead of the crop tool, this should allow you to use an action or script which triggers a crop command and a save as command.

Sorry, I didn’t mention in the first post but unfortunately the crop size and placement is always different.
For 3 out of the 8 photos per patient set, the crop field is a more portrait aspect ratio, and for the other 5, it’s landscape. The placement of this area changes all the time. The landscape ones are 1024 x 683px, and the portrait ones are 512 x 768px (it’s more a crop+resize than just a crop). This is so they fit into appropriate boxes on the database program.

I wish it were as simple as the solution you’ve suggested, but unfortunately to get the placement and size of the box in the same place every time, the photos would all need to be taken in exactly the same place. This is quite hard since there’s 3 different people who take the photos, and some of the patients are kids who might not be able to keep their head in place.

If I were to use a rectangular marquee, I would need a way of easily switching between the landscape and portrait aspect ratios, but unlike the crop tool, I can’t save multiple tools (I don’t think so anyway).

Thanks for the suggestion and the fast response though :slight_smile:

I don’t know if this is going to make life easier and save you much time but you could record 2 actions and have a script determine which to use. In my tests here I can record the 2 Fixed Aspect Ratio Crops (I usually record them from top left and to size) apply then stop recording the action for both. Then when you use the following script only the dialogs for the actions will be shown. The actions must have the dialogs toggled “ON” in the GUI this will then present the user with the required crop you just need to reposition and scale to suite your needs then keystroke “return” the script would then move on to its next task. I have not tested but you may be able to wrap the “do action” in time out blocks if you need longer than the AppleScript standard.

tell application "Adobe Photoshop CS2"
	set User_Notifiers to notifiers enabled
	set User_Rulers to ruler units of settings
	set User_Dialogs to display dialogs
	set notifiers enabled to false
	set ruler units of settings to pixel units
	set display dialogs to never
	set foreground color to {class:RGB color, red:0.0, green:0.0, blue:0.0}
	set background color to {class:RGB color, red:255.0, green:255.0, blue:255.0}
end tell
tell application "Adobe Photoshop CS2"
	-- open The_File
	set Doc_Ref to the current document
	tell Doc_Ref
		set Pixel_Height to height
		set Pixel_Width to width
		if Pixel_Height > Pixel_Width then
			-- It portrait
			do action "768x512" from "Marks" with display dialogs
			-- save doc
			-- Its Landscape
			do action "1024x683" from "Marks" with display dialogs
			-- save doc
		end if
		-- Close doc
	end tell
end tell
tell application "Adobe Photoshop CS2"
	set notifiers enabled to User_Notifiers
	set ruler units of settings to User_Rulers
	set display dialogs to User_Dialogs
end tell