If we’d all been living in California…
…and we were all running Mac OS 9, and we all had an entirely non-AppleScriptable version of Photoshop (say v3.05, circa 1995), and a handy little key macro program called KeyQuencer, we could use the script below to resize and touch up all our pics just by dragging them to a single icon.
Still works in Classic on 10.4.3.
Peter B.
property image_res : ""
property image_size : ""
property image_levels : ""
property image_mask : ""
property image_width : ""
property image_height : ""
property mask_amount : ""
property mask_radius : ""
tell me to activate
display dialog "Set Image Targets..." & return & return & ¬
"Resolution: " & image_res & return & "Size: " & image_size & return & ¬
"Level Adjustment: " & image_levels & return & ¬
"Unsharp Mask: " & image_mask & return ¬
buttons {"Cancel", "Use Current Settings", "Reset"} default button 3
set button_returned to button returned of result
if button_returned is "Reset" then
tell me to activate
display dialog "Set Target Resolution..." buttons {"144", "96", "72"} default button 3
set image_res to button returned of result
KeyQuencer Set Variable "imageRes" to image_res
tell me to activate
choose from list {"Icon", "Small Thumbnail", "Medium Thumbnail", "Large Thumbnail", "320 x 240", "640 x 480", "800 x 600", "912 x 684", "1024 x 768", "1280 x 960"} with prompt ¬
"Set Target Size..." default items image_size
set image_size to the result as text
if image_size is "false" then
set image_size to "640 x 480"
return
error -128
tell me to quit
end if
if image_size is "Icon" then
set image_width to "128"
set image_height to ""
KeyQuencer Set Variable "imageWidth" to image_width
KeyQuencer Set Variable "imageHeight" to image_height
end if
if image_size is "Small Thumbnail" then
set image_width to "80"
set image_height to ""
KeyQuencer Set Variable "imageWidth" to image_width
KeyQuencer Set Variable "imageHeight" to image_height
end if
if image_size is "Medium Thumbnail" then
set image_width to "160"
set image_height to ""
KeyQuencer Set Variable "imageWidth" to image_width
KeyQuencer Set Variable "imageHeight" to image_height
end if
if image_size is "Large Thumbnail" then
set image_width to "240"
set image_height to ""
KeyQuencer Set Variable "imageWidth" to image_width
KeyQuencer Set Variable "imageHeight" to image_height
end if
if image_size is in {"320 x 240", "640 x 480", "800 x 600", "912 x 684", "1024 x 768", "1280 x 960"} then
set _Priors to AppleScript's text item delimiters
set AppleScript's text item delimiters to " x "
set image_dims to every text item of image_size
set image_width to text item 1 of image_dims
set image_height to ""
set AppleScript's text item delimiters to _Priors
KeyQuencer Set Variable "imageWidth" to image_width
KeyQuencer Set Variable "imageHeight" to image_height
end if
tell me to activate
choose from list {"0.8", "0.9", "1.0", "1.1", "1.2", "1.3", "1.4"} with prompt ¬
"Set Target Level Adjustment..." default items image_levels
set image_levels to the result as text
KeyQuencer Set Variable "imageLevels" to image_levels
if image_levels is "false" then
set image_levels to "1.0"
return
error -128
tell me to quit
end if
tell me to activate
choose from list {"None", "240 / .2", "360 / .2", "480 / .2", "120 / .3", "240 / .3", "360 / .3"} with prompt ¬
"Set Target Unsharp Mask..." default items image_mask
set image_mask to the result as text
if image_mask is "false" then
set image_mask to "None"
return
error -128
tell me to quit
end if
if image_mask is "None" then
set mask_amount to "1"
set mask_radius to ".1"
KeyQuencer Set Variable "maskAmount" to mask_amount
KeyQuencer Set Variable "maskRadius" to mask_radius
end if
if image_mask is in {"240 / .2", "360 / .2", "480 / .2", "120 / .3", "240 / .3", "360 / .3"} then
set _Priors to AppleScript's text item delimiters
set AppleScript's text item delimiters to " / "
set mask_items to every text item of image_mask
set mask_amount to text item 1 of mask_items
set mask_radius to text item 2 of mask_items
set AppleScript's text item delimiters to _Priors
KeyQuencer Set Variable "maskAmount" to mask_amount
KeyQuencer Set Variable "maskRadius" to mask_radius
end if
end if
-----
on open these_items
if image_size is "" then
tell me to activate
display dialog "No Image Targets Have Been Set..." & return & return & ¬
"Click On This App's Icon to Set Defaults." buttons {"Cancel"} default button 1
end if
--
KeyQuencer Set Variable "imageRes" to image_res
KeyQuencer Set Variable "imageWidth" to image_width
KeyQuencer Set Variable "imageHeight" to image_height
KeyQuencer Set Variable "imageLevels" to image_levels
KeyQuencer Set Variable "maskAmount" to mask_amount
KeyQuencer Set Variable "maskRadius" to mask_radius
--
tell application "Photoshop"
activate
end tell
tell application "Finder"
open these_items using application file id "8BIM"
set these_items to the reverse of these_items
end tell
repeat with this_item in these_items
set new_file to (path to desktop as text) & "Untitled Image"
tell application "Finder"
set this_item to this_item as text
set file_name to the name of file this_item
set _date to creation date of file this_item
if _date is missing value then
set _date to modification date of file this_item
end if
end tell
set orig_date to ""
if file_name contains " " then
set _Priors to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set file_name_items to every text item of file_name
set file_name to text item 1 of file_name_items
set _prefix to "=>"
set AppleScript's text item delimiters to _Priors
end if
if file_name contains "." then
set _Priors to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set file_name_items to every text item of file_name
set file_name to text item 1 of file_name_items
set _prefix to "=>"
set AppleScript's text item delimiters to _Priors
end if
if file_name does not end with ".jpg" or file_name does not end with ".JPG" then
set file_name to file_name & ".jpg"
set _prefix to "=>"
end if
if file_name starts with "DSC" then
set file_name to characters -7 through -1 of file_name as text
set file_name to file_name
set _prefix to "=>"
end if
if file_name starts with "=>" then
set _Priors to AppleScript's text item delimiters
set AppleScript's text item delimiters to "_"
set file_name_items to every text item of file_name
set orig_date to text item 2 of file_name_items
set file_name to text item 3 of file_name_items
set _prefix to "==>"
set AppleScript's text item delimiters to _Priors
end if
if file_name starts with "==>" then
set _Priors to AppleScript's text item delimiters
set AppleScript's text item delimiters to "_"
set file_name_items to every text item of file_name
set orig_date to text item 2 of file_name_items
set file_name to text item 3 of file_name_items
set _prefix to "===>"
set AppleScript's text item delimiters to _Priors
end if
set _year to year of _date as text
set _month to month of _date as text
set _day to day of _date as text
set year_integer to characters 3 through 4 of _year
if the (count of characters of _day) is 1 then
set day_integer to "0" & _day
else
set day_integer to _day
end if
if _month is "January" then
set month_integer to "01"
end if
if _month is "February" then
set month_integer to "02"
end if
if _month is "March" then
set month_integer to "03"
end if
if _month is "April" then
set month_integer to "04"
end if
if _month is "May" then
set month_integer to "05"
end if
if _month is "June" then
set month_integer to "06"
end if
if _month is "July" then
set month_integer to "07"
end if
if _month is "August" then
set month_integer to "08"
end if
if _month is "September" then
set month_integer to "09"
end if
if _month is "October" then
set month_integer to "10"
end if
if _month is "November" then
set month_integer to "11"
end if
if _month is "December" then
set month_integer to "12"
end if
set YY_MM_DD to year_integer & "-" & month_integer & "-" & day_integer as text
--
if orig_date is "" then
set YY_MM_DD to YY_MM_DD
else
set YY_MM_DD to orig_date
end if
--
try
tell application "Photoshop"
activate
KeyQuencer Do Macro "WaitUpdates 5 seconds
Menu \"Image Size...\" quiet continue
Type $imageRes
Key tab
Type $imageWidth
Key tab
Type $imageHeight
Key enter
Menu submenu \"Levels...\" quiet continue
Key tab
Type $imageLevels
Key enter
Menu submenu \"Unsharp Mask...\" quiet continue
Type $maskAmount
Key tab
Type $maskRadius
Key Enter
Menu \"Save As...\" quiet continue
Button \"Desktop\" quiet continue
PopUpMenu button 6 \"JPEG\" quiet continue
Type \"Untitled Image\"
Key enter
Key enter
Key cmd \"w\""
end tell
on error
return
error -128
end try
tell application "Finder"
repeat until exists file new_file
end repeat
try
folder "Resized Images" of the desktop
on error
make new folder at desktop with properties {name:"Resized Images"}
end try
set creator type of file new_file to "ogle"
set the name of file new_file to _prefix & image_width & "_" & YY_MM_DD & "_" & file_name
set resized_image to (the desktop as text) & _prefix & image_width & "_" & YY_MM_DD & "_" & file_name
try
move file resized_image to folder "Resized Images" of the desktop
on error
tell me to activate
display dialog ¬
"An Item By The Same Name Already Exists In The Target Folder..." & ¬
return & return & "Would You Like To Rename This Item?" & ¬
return & return default answer file_name
set new_name to text returned of the result
set the name of file resized_image to _prefix & image_width & "_" & YY_MM_DD & "_" & new_name
set resized_image to (the desktop as text) & _prefix & image_width & "_" & YY_MM_DD & "_" & new_name
move file resized_image to folder "Resized Images" of the desktop
end try
end tell
end repeat
tell application "Finder"
update folder "Resized Images" of the desktop
open every file of folder "Resized Images" of the desktop
end tell
end open