Photoshop CS Help!

I am working on a script that does the following:

Sets the background color to grey
Opens a file
Changes the mode to RGB
Cuts the content of the background layer and places it on a new layer
Resizes the file
Resizes the canvas
Adds a drop shadow (using styles)

Opens a second file based on a random number between 1 and 4 (first file is
still open)
Copies the contents of a layer of the second file
Closes the second file

Paste the contents of the second file to a new layer of the first file
Selects the contents of the new layer and rotates it

It’ll do more but this is as far as I am right now. Problem is when I go to
rotate the contents of the new layer in the first file PS gives me an error
message which reads that the current document contains no selection. But it
clearly does as I have “select all” in the script and if I stop the script
at this point I can go into the PS file and cut, copy, rotate, etc the
contents of the layer I was targeting. I can even cut the contents using AS.
But I can’t rotate it.

K-pase-huh?

Any help would be appreciated. Script follows:

=====================================================================

set thePath to (path to desktop as string) & “pictureTest:images:”
set tapePath to (path to desktop as string) & “pictureTest:items:tape”
set theFileList to list folder thePath without invisibles

repeat with thisFile in theFileList
tell application “Adobe Photoshop CS”
set thisFilePath to (thePath as string) & thisFile as alias
activate
set background color to {class:RGB color, red:204, green:204,
blue:204}
open thisFilePath
change mode of current document to RGB
select all of current document
cut selection of current document
make new art layer at beginning of current document with properties
{name:“Image Layer”}
paste selection
–set docRefInfo to info of current document
set theWidth to width of current document
set theHeight to height of current document
if theWidth > theHeight then
resize image of current document width 175 resolution 72
resize canvas of current document width 200 height 200 anchor
position middle center
else
resize image of current document height 175 resolution 72
resize canvas of current document width 200 height 200 anchor
position middle center
end if

    set newWidth to width of current document
    set newHeight to height of current document
    
    --apply shadow layer style - it's case sensitive
    apply layer style art layer "Image Layer" of current document using

“tapeShadow2”

    --repeat with i from 1 to 4
    --get random number
    set thisTapeFile to random number 4
    if thisTapeFile = 0 then
        set thisTapeFile to thisTapeFile + 1
    end if
    
    --subroutine to add tape to page
    my tapeTheImage(thisTapeFile, tapePath)
    --end repeat
    --close current document saving no
    
end tell

end repeat


–Subroutines

on tapeTheImage(thisTapeFile, tapePath)
set i to 1
set openThisFile to (tapePath as string) & thisTapeFile & “.psd” as
alias
tell application “Adobe Photoshop CS”
open openThisFile
tell current document
set current layer to layer “tape”
select all
copy
close saving no
end tell

    --determining where to put the tape
    if i = 1 then
        tell current document
            paste
            set current layer to layer "Layer 1"
            select all
            rotate selection angle 45
        end tell
    end if
end tell

end tapeTheImage

Have you tried recording the action you want to do in Photoshop, then use AppleScript to call that action?

I’m doing just that with my Script:

on run
	display dialog "To use this script, please drag files onto its Finder icon"
end run

on open myFinderList
	repeat with myFinderItem in myFinderList
		tell application "Finder" to set myItemIsFolder to (kind of myFinderItem = "folder")
		if myItemIsFolder then
			tell application "Finder" to set myFolderContents to (every item of myFinderItem)
			open myFolderContents
		else
			set theDay to the day of (current date)
			set theMonth to the month of (current date)
			set theDate to theDay & " " & theMonth
			set ConvertedFolder to (path to desktop folder) & "Converted " & theDate & ":" as string
			
			try
				get ConvertedFolder as alias
			on error
				tell application "Finder"
					set targetFolder to make new folder at (path to desktop folder) with properties {name:"Converted " & theDate}
				end tell
			end try
			
			with timeout of 864000 seconds
				tell application "Adobe Photoshop CS"
					set ConvertThis to open (myFinderItem as alias)
					set myDocumentName to "edit " & name of current document
					set myDocumentPath to ConvertedFolder & myDocumentName as string
					do action "Change Size" from "AppleScripts"
					save current document in myDocumentPath as JPEG with options {class:JPEG save options, quality:12}
					close current document
				end tell
			end timeout
			
		end if
	end repeat
		display dialog "All your Photos have been converted." buttons {"OK"} default button 1 with icon stop giving up after 10
end open

You’ll need to change the “do action” & the “save” bit. Also I have slight problem with the last dialog box showing twice if a folder is dropped on the script.

Hope this is of some help.
Ben.

It should be

rotate current layer angle 45

not rotate selection

Not sure why but what the hey, it works.