Player
Cool Uses
Photoshop
-- example script for batch processing a folder full of images using Player to drive Photoshop
-- by PreFab Software, Inc., June 1996, for Player 1.1b5
-- batch convert a folder full of images to GIF
-- reduce size by 33%, sharpen 12% (Unsharp Mask), increase contrast 8%
-- use the Scriptable Finder to get a list of images that are not already of type "GIFf"
-- if an image is CMYK, first have to convert to RGB, then to Indexed Color
-- accept the defaults in "Indexed Color" dialog
-- grayscale images are left in grayscale
set theFolder to choose folder
-- set theFolder to "Disk:folder:"
tell application "Finder"
set listOfFiles to (get every file of folder theFolder whose file type is not "GIFf") as list
-- or: set listOfFiles to files in folder theFolder
end tell
if listOfFiles is {} then
display dialog "There are no non-GIF files in that folder."
return false -- abort
end if
tell application "Adobe Photoshopª 3.0" to activate
app menu "Hide Others" -- avoids some of the screen refresh
repeat with theFile in listOfFiles
tell application "Adobe Photoshopª 3.0" to activate -- in case another app got brought to the front
tell application "Finder" to open theFile
-- to open a file created by an app other than Photoshop:
-- tell application "Finder" to open theFile using "disk:folder:Adobe Photoshopª 3.0"
-- ... or possibly: using application "Adobe Photoshopª 3.0" of folder "whatever" of disk "whatever"
-- the following functions are defined below
my reduceSize(33) -- percent
my sharpen(12) -- percent
my increaseContrast(8) -- percent
my convertToGIF()
tell application "PreFab Playerª"
do menu menu item "Close" of menu "File" -- if needed, add "repeat until successful"
end tell
end repeat
activate me
display dialog "Done processing folder!"
on increaseContrast(percent)
tell application "PreFab Playerª"
do menu menu item "Brightness/Contrast" of submenu "Adjust" of menu "Image"
type {tab, percent, enter} -- contrast is the second item
-- type tab & percent & enter -- this form works too
end tell
end increaseContrast
on sharpen(percent)
tell application "PreFab Playerª"
do menu menu item "Unsharp Mask" of submenu "Sharpen" of menu "Filter"
type {percent, enter}
-- type percent & enter -- this form works too
end tell
end sharpen
on reduceSize(percent)
tell application "PreFab Playerª"
set scaleFactor to (100 - percent)
set widthPopup to 5
set heightPopup to 4 -- not using at the moment
do menu menu item "Image Size" of menu "Image"
-- I think the "proportions" checkbox is always checked when the dialog opens
-- (even if previously unchecked)
-- if not, add "do popup" for the heightPopup here
-- and type another tab & scaleFactor below
do menu popup item "percent" of popup widthPopup -- the FIRST popup
-- click location widthPopup -- extra click not required in 1.1
-- the contents are highlighted (by selecting something in the popup), therefore just type
-- break the type command into separate lines if you need a short delay
type {scaleFactor, enter}
-- type scaleFactor & enter -- this form works too
end tell
end reduceSize
on convertToGIF()
-- GIF files must be grayscale or indexed color
-- could enhance to set options for indexed color
-- warning: if filename is maximum number of chars, the original file will be replaced
-- if close to the max, ".gif" will be truncated
tell application "PreFab Playerª"
if checked of (get info menu item "CMYK" of menu "Mode") then
do menu menu item "RGB" of menu "Mode"
end if
if checked of (get info menu item "RGB" of menu "Mode") then
do menu menu item "Indexed Color" of menu "Mode"
-- there are many options in the dialog; just accept defaults for now
type enter
end if
do menu menu item "Save As" of menu "File"
do menu popup item "CompuServe GIF" of popup "Format"
-- click dialog item "Format" -- extra click not required in 1.1
type {right arrow, ".GIF", enter}
if exists button "Replace" then
click button "Replace"
end if
end tell
end convertToGIF
Save to Done Folder
Copyright 1993-97, PreFab Software, Inc. All Rights Reserved.
This site built and maintained using Stage Three, a set of custom Frontier scripts.