Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Demo AppleScript for making web versions of print images
-- examples, replace with yours
set print_images to ¬
{"/Users/jeffsternberg/Desktop/catalog/image_1.psd", ¬
-- main loop
repeat with print_image in print_images
end repeat
-- convert an image to RGB, then save 4 smaller web friendly JPEGs
on process_image(print_image)
set image_name to remove_extension(print_image)
tell application "Adobe Photoshop 2020"
open file print_image
tell current document
change mode to RGB
repeat with new_width in {600, 400, 200, 100}
tell me to make_web_copy(image_name, new_width)
end repeat
close without saving
end tell
end tell
end process_image
-- resize, save as jpeg, revert
on make_web_copy(image_name, new_width)
tell application "Adobe Photoshop 2020"
tell current document
set revert_state to the current history state
resize image width new_width ¬
resample method bicubic smoother
save as JPEG in file (image_name & "_" & new_width) ¬
appending lowercase extension with copying
set the current history state to revert_state
end tell
end tell
end make_web_copy
-- from
on remove_extension(this_name)
if this_name contains "." then
set this_name to ¬
(the reverse of every character of this_name) ¬
as string
set x to the offset of "." in this_name
set this_name to (text (x + 1) thru -1 of this_name)
set this_name to ¬
(the reverse of every character of this_name) ¬
as string
end if
return this_name
end remove_extension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment