I turned mine into a FaceSPan app, so the entire script is not very useful (FaceSpan-specific user interface bits), but here’s the main prepping/sizing/saving routines:
--convert user answer to JPEG quality to Photoshop's numeric notation
if JPEG_quality = "Medium" then
set JPEG_quality to 5
else
if JPEG_quality = "High" then
set JPEG_quality to 8
else
if JPEG_quality = "Maximum" then
set JPEG_quality to 12
end if
end if
end if
--step through files
repeat with i from 1 to count of items of g_dropped_items
(* Needed only outside FaceSpan?
set parseMeString to (item i of g_dropped_items) as string
set parseMeStringPOSIX to POSIX path of parseMeString
logMe("¢ POSIX Conversion Completed", 2)
*)
--get file name without extension
tell (info for item i of g_dropped_items without size) to set {file_name, file_extension} to {name, name extension}
set file_name to text 1 thru -((count file_extension) + 2) of file_name
logMe("¢ File name without extension: " & file_name, 2)
--rename file to indicate it was converted by script
set new_file_name to file_name & file_suffix & ".jpg"
logMe("¢ File name with extension: " & new_file_name, 2)
try
tell application "Adobe Photoshop CS4"
my logMe("Photoshop Work Started", 3)
activate
open file (item i of g_dropped_items as string)
--open file (parseMeStringPOSIX as text) --for outside FaceSpan
--set document units to pixels (resize command only uses ppi)
set ruler units of settings to pixel units
--fix pixel aspect ratio
set pixel aspect ratio of current document to 1.0
tell current document
--get height and width of current document
set current_height to height
set current_width to width
--flatten image
flatten
--set image resolution
resize image resolution file_res resample method none
--if user requested inches, convert dimensions to ppi in-place (resize command needs ppi)
if working_units is "Inches" then
set new_height to (new_height * file_res)
set new_width to (new_width * file_res)
end if
--change to RGB (CMYK not web compatible)
change mode to RGB
end tell
--set background for padding (canvas resize)
set background color to {class:RGB color, red:255, green:255, blue:255}
--remove extra channels
set safe_channels to {"Red", "Green", "Blue"}
set channel_names to name of channels of current document
repeat with c from 1 to number of items in channel_names
if (item c of channel_names) is not in safe_channels then
delete channel (item c of channel_names) of current document
end if
end repeat
--figure out reduction percentages
set height_ratio to new_height / current_height
set width_ratio to new_width / current_width
--make sure is not enlargement
if (height_ratio < 1) or (width_ratio < 1) then
--pick out smallest reduction and use that
if height_ratio ≤ width_ratio then
resize image current document height new_height resample method bicubic
else
if width_ratio < height_ratio then
resize image current document width new_width resample method bicubic
end if
end if
end if
--pad image if required
if pad_image is "Yes" then
resize canvas current document width new_width height new_height anchor position middle center
end if
my logMe("¢ Image Padded (if needed)", 3)
--create path to destination
my logMe("¢ Build File Path and Name", 3)
set new_file_location to ((save_location as Unicode text) & "/" & new_file_name)
my logMe("¢ Destination Path Built: " & new_file_location, 4)
--create reference (required for Photoshop saves)
set new_file_reference to (a reference to file new_file_location)
my logMe("¢ File Reference Created", 4)
--save and close file
save current document appending lowercase extension as JPEG in new_file_reference with options {embed color profile:false, format options:optimized, quality:JPEG_quality}
close current document
my logMe("¢ Save Completed", 3)
--set completed file label to green
tell application "Finder" to set label index of (item i of g_dropped_items) to 6
end tell
on error
activate
display alert file_name message "Unable to process this file, it will be skipped."
--set uncompleted file label to red
tell application "Finder" to set label index of (item i of g_dropped_items) to 2
end try
end repeat
logMe("processFiles Ended", 0)
quit application
Yes, I really do comment most of my scripts with this detail…I’m often very rushed, or doing scripts in 15-30 minute bursts then go weeks before getting back to them. I need the comments to jog my memory. 
The logMe entries reference my generic log-to-a-text-file routine, handy during troubleshooting, switched-off when I’m done.
The reason for the near-absurd level of stepping through removal of all that stuff is that Save for Web doesn’t quite “dejunk” files from Photoshop well enough for some unix-side database systems.
For example, our web group complained that the JPEGs I was giving them weren’t working because PHP/mySQL does not like the extraneous “resolution” information Photoshop embeds in JPEGs (among other things). Photoshop can save a “300dpi JPEG” but the JPEG technical standards apparently only allow for 72dpi…and PHP/mySQL are apparently very literal in this regard.
I found stripping all offending Photoshop elements and explicitly setting things like resolution solved the problem. Thus all the hoops I had to jump through, since we’re often converting complex, layered, high-res, multi-channel files.