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
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