Can't copy filename to clipboard or set variable to it

I’m trying to process some images using Image Events.

I need to capture the original file name of the image file, enter it into a field in Filemaker Pro 7, extract the resolution into two fields, then save a thumbnail image in a new location with a new filename.

In my display dialog, I just get the first character of the filename set to variable OriginalName.

For now I would like to see that I have captured the filename.

Here’s the code (try it, it should work anywhere!):

set this_file to choose file
try
	tell application "Image Events"
		launch
		-- open the image file
		set this_image to open this_file
		-- extract the property value
		copy the dimensions of this_image to {xres, yres}
		copy the name of this_file to {originalname}
		-- purge the open image data
		close this_image
	end tell
	display dialog "The file " & (originalname as string) & " Resolution is " & (((xres as string) & " by " & yres as string) & " pixels")
on error error_message
	display dialog error_message
end try

Thanks - I can use any help ASAP!! :wink:

Hi,

This is because you are turning a string into a list and only storing the first character. Here is a simpler example of what’s happening:

set {myItem} to "hello"
display dialog myItem
set {myItem, myItem2, myItem3, myItem4, myItem5} to "hello"
display dialog myItem
display dialog myItem2
display dialog myItem3
display dialog myItem4
display dialog myItem5

Remove the curly (list making) brackets from your variable originalname and it will store the whole string.

set this_file to choose file
try
	tell application "Image Events"
		launch
		-- open the image file
		set this_image to open this_file
		-- extract the property value
		copy the dimensions of this_image to {xres, yres}
		copy the name of this_file to originalname
		-- purge the open image data
		close this_image
	end tell
	display dialog "The file " & (originalname as string) & " Resolution is " & (((xres as string) & " by " & yres as string) & " pixels")
on error error_message
	display dialog error_message
end try

Best wishes

John M

So THAT’s what the brackets are for!!

Thanks!! I’m definately a newbie, and trying to get this done.

Stay tuned . . . I may need more little tidbits like this!

Thanks again,
SoCalMacDude