How to add watermark to photo with photoshop

I will be needing a script to batch add watermarks to photos on a regular basis. I have a copy of CS5 on my computer and I know that it comes with an applescript dictionary, which is why I am using photoshop. If there is a better way please let me know. Anyway this is what I have so far and I’m not having any luck:

on open some_items
	repeat with this_item in some_items
		try
			add_watermark(this_item)
		end try
	end repeat
end open

to add_watermark(this_item)
	tell application "Adobe Photoshop CS5"
		launch
		set this_image to open this_item
		set watermark to "/Users/aaon/Desktop/Untitled-1.png"
		set watermark_layer to make new art layer in this_image
		set contents of watermark_layer to watermark
	end tell
	
end add_watermark

When I get this script all wrote up nice and working I want to have two versions one that puts the watermark over the entire photo and one where it just puts it in the bottom corner.

Borrowing from this thread http://macscripter.net/viewtopic.php?id=20631 I went the route of creating actions in Photoshop and calling them from my applescript. Problem I am getting now is I want this process to be completely automated. I don’t want to have to click the save button for each picture.

This is my script:

set processFolder to choose folder with prompt "Choose a folder that contains images to process"
set targetFolder to choose folder with prompt "Choose a folder to save processed images"
set listImages to list folder processFolder without invisibles
repeat with i from 1 to (length of listImages)
	set thisimage to item i of listImages
	set image_file_path to (processFolder & thisimage as string)
	
	tell application "Adobe Photoshop CS5"
		open file image_file_path
		do action "WP" from "Default Actions.atn"
		save current document as JPEG in targetFolder
		close current document
	end tell
end repeat

And as you can see I am using the save command in the targetFolder but when it gets to that part in the script it prompts me to save and the folder it defaults saving to is the folder the image came from and not the target folder.

Hi,

does this help?


.
close current document saving no
.

Thanks for the reply. It still prompts me to save and I’m pretty sure its the save current document as jpeg in targetfolder that is trowing the prompt. Plus it doesn’t default to the targetFolder.

probably you must specify the whole string path


set processFolder to choose folder with prompt "Choose a folder that contains images to process"
set targetFolder to choose folder with prompt "Choose a folder to save processed images"
tell application "Finder" to set listImages to files of processFolder as alias list

repeat with oneImage in listImages
	set {name:Nm, name extension:Ex} to (info for oneImage)
	set baseName to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
	
	set destinationPath to (targetFolder as text) & baseName & ".jpg"
	tell application "Adobe Photoshop CS5"
		open oneImage
		do action "WP" from "Default Actions.atn"
		save current document as JPEG in destinationPath
		close current document saving no
	end tell
end repeat


That got one problem out of the way. The prompt still happens but at least it’s defaulting to the targetFolder. I can probably just have applescript send a keystroke return and that should take care of that. I would like to not see the save prompt all together, but beggers cant be choosers

+Edit

Well that doesn’t work as planned. I added the keystroeks and the beeps just to know where ths cript was at but it wikk just sit at the save prompt.


set processFolder to choose folder with prompt "Choose a folder that contains images to process"
set targetFolder to choose folder with prompt "Choose a folder to save processed images"
tell application "Finder" to set listImages to files of processFolder as alias list

repeat with oneImage in listImages
	set {name:Nm, name extension:Ex} to (info for oneImage)
	set baseName to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
	
	set destinationPath to (targetFolder as text) & baseName & ".jpg"
	tell application "Adobe Photoshop CS5"
		open oneImage
		do action "Watermark" from "Default Actions.atn"
		save current document as JPEG in destinationPath
	end tell
	delay 0.5
	beep
	tell application "System Events"
		keystroke return
		delay 0.2
		keystroke "12"
		delay 0.2
		keystroke return
	end tell
	beep
	beep
	beep
	tell application "Adobe Photoshop CS5" to close current document saving no
	
	
end repeat


two suggestions

insert this line right after the tell application Photoshop. line


.
set display dialogs to never
.

add the keyword file


.
save current document as JPEG in file destinationPath
.

Forget the GUi scripting part

Sah-Freaking-Wheat!!! Stephan every time I’ve had an issue you have came to my rescue. I am forever in your debt. But I use the word forever loosely. :smiley:

You should write a book Stephen K On Applescript