Hi there,
I'm new to this forum and also generally new to Applescript. What I've been trying to do is to create an application to 1) Square a bunch of images and save them to a folder and then 2) Load those squared images and resize them into various different dimensions. Here is my code:
The place where I'm running into a problem is some where around these lines: "set a_list to every file in source_folder as alias list
repeat with i from 1 to number of items in a_list
display dialog a_list
set a_file to (item of a_list)".
It seems that the function "rescale_and_save_750" is never actually entered because the dialogue in that function never displays. I am getting an error that says "Can't make {alias "file name and path"} into type string." Does anybody know what exactly I'm doing wrong? I know that the resize to 750 function itself and the square function itself are both working seamlessly as I tried them individually and they worked. Again, I'm a newbie at this and would REALLY appreciate any help.
--Will
I'm new to this forum and also generally new to Applescript. What I've been trying to do is to create an application to 1) Square a bunch of images and save them to a folder and then 2) Load those squared images and resize them into various different dimensions. Here is my code:
Code:
-----------------------------------------------------------
-----------------------------------------------------------
-- save in Script Editor as Application
-- drag files to its icon in Finder
property save_folder : "Users:username:Desktop"
property type_list : {"TIFF", "JPEG", "PNGf", "PICT"}
property extension_list : {"tif", "tiff", "jpg", "jpeg", "png", "pict", "pct"}
on open some_items
do shell script "mkdir -p '/Users/username/Desktop/ImageResizing'"
do shell script "mkdir -p '/Users/username/Desktop/ImageResizing/Squared'"
do shell script "mkdir -p '/Users/username/Desktop/ImageResizing/750/'"
repeat with this_item in some_items
try
make_square(this_item)
end try
end repeat
tell application "Finder"
display dialog "Telling app finder"
set source_folder to "Macintosh HD:Users:username:Desktop:ImageResizing:Squared:" as alias
set a_list to every file in source_folder as alias list
repeat with i from 1 to number of items in a_list
display dialog a_list
set a_file to (item of a_list)
rescale_and_save_750(a_file)
end repeat
end tell
end open
to make_square(this_item)
tell application "Finder"
set folder_path to "Users:username:Desktop:ImageResizing:Squared:"
set file_path to (folder_path)
end tell
tell application "Image Events"
launch
-- open the image file
set this_image to open this_item
set typ to this_image's file type
copy dimensions of this_image to {current_width, current_height}
if current_width is greater than current_height then
set pad_dimensions to {current_width, current_width}
pad this_image to dimensions pad_dimensions with pad color {65535, 65535, 65535}
else if current_height is greater than current_width then
set pad_dimensions to {current_height, current_height}
pad this_image to dimensions pad_dimensions with pad color {65535, 65535, 65535}
end if
end tell
save this_image in file_path as typ
end make_square
to rescale_and_save_750(this_item)
display dialog "I'm in 750"
tell application "Finder"
display dialog "I'm in 750"
set folder_path to "Users:username:Desktop:ImageResizing:750:"
set file_path to (folder_path)
end tell
tell application "Image Events"
launch
set the target_width to 750
-- open the image file
set this_image to open this_item
set typ to this_image's file type
set the target_width to 750
set the target_height to 750
copy dimensions of this_image to {current_width, current_height}
if current_width is greater than target_width then
scale this_image to size target_width
else if current_height is greater than target_height then
scale this_image to size target_width
end if
end tell
save this_image in file_path as typ
end rescale_and_save_750
-----------------------------------------------------------
-----------------------------------------------------------
The place where I'm running into a problem is some where around these lines: "set a_list to every file in source_folder as alias list
repeat with i from 1 to number of items in a_list
display dialog a_list
set a_file to (item of a_list)".
It seems that the function "rescale_and_save_750" is never actually entered because the dialogue in that function never displays. I am getting an error that says "Can't make {alias "file name and path"} into type string." Does anybody know what exactly I'm doing wrong? I know that the resize to 750 function itself and the square function itself are both working seamlessly as I tried them individually and they worked. Again, I'm a newbie at this and would REALLY appreciate any help.
--Will
Last edited by a moderator: