Image Events not recognizing "scale" message

Hello,

based on this thread http://bbs.applescript.net/viewtopic.php?id=14167

I have this snippet that gives an error “Finder got an error: item 1 of {document file “ati-x800.jpg” of folder “Pictures” of folder “holbrook” of folder “Users” of startup disk} doesn’t understand the scale message.”

I know it must be something stupid I am doing.

Here is the script:

property theSize : 0.5

tell application "Finder"
	set theFiles to selection
end tell

if (count of theFiles) is not 0 then
	repeat with theFile in theFiles
		tell application "Image Events"
			launch
			open theFile
			scale theFile by factor theSize
			save theFile
			close theFile
		end tell
	end repeat
end if

If I change it to

property theSize : 0.5

tell application "Finder"
	set theFiles to selection
end tell

if (count of theFiles) is not 0 then
	repeat with theFile in theFiles
		tell application "Image Events"
			launch
			set theImage to (open theFile)
			scale theImage by factor theSize
			save theImage in theFile
			close theImage
		end tell
	end repeat
end if

Then I get the Applescript Runtime Error “the variable theImage is not defined” on the “scale” line.

Can anyone see where I screwed up here? Thanks!!!

The scaling line I use (which works) goes like this:


tell application "Image Events"
	launch
	set theImage to open theImage
	tell theImage
		scale to size newS
		save in newPath
		close
	end tell

I use the same thing as Adam.

tell application "Image Events"
	launch
	open theImage
	
	tell result
		scale to size newS
		save in newPath
		close
	end tell
end tell

Thanks.

The problem was that the code

tell app “Finder” to set theFiles to selection
repeat with theFile in theFiles

sets “theFile” to item 1 of a list, rather than an alias.

Coding "set theFile to (theFile as alias) fixed it.

I think I also could have coded

tell app “Finder” to set theFiles to selection as alias list

Thanks again, everyone.