I can’t figure this one out. I get all sorts of error of wrong “type”.
Here is the basic script (which I got from Apple’s site)
property type_list : {"TIFF", "JPEG", "PNGf", "PICT"}
property extension_list : {"tif", "tiff", "jpg", "jpeg", "png", "pict", "pct"}
tell application "Finder"
activate
try
set these_items to the selection
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
if the file type of this_item is in the type_list or ¬
name extension of this_item is in the extension_list then
set this_path to this_item as string
tell application "Image Events"
set this_image to open file this_path
-- IMAGE PROCESSING STATEMENTS GO HERE
--get dimensions of this_image
scale this_image to size 640
save this_image with icon
close this_image
end tell
-- FINDER ACTIONS SUCH AS MOVE, DUPLICATE, OR DELETE GO HERE
end if
end repeat
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
end tell
So, the place where I’ve put get dimensions is where I have problems.
I tried
if dimensions of this_image is greater than 640 then
It gives me the Type error.
If I tried to get the dimensions. It works, but returns a list of two items. I’ve tried getting the items of the list by setting them individually like this.
set my_width to (item 1 of dimensions of this_image)
I tried to put as string at the end and still get an error message.
I know this must be super easy, but I can’t figure it out. All I want to do is to scale the image only if one of it’s sides is larger then 640.
TIA
Jeff