I'm using Automator for the first time, trying to manipulate (resize and pad) many images at once. I've created a workflow that consists of several actions and an AppleScript at the end to perform some basic If/Then logic (since my images are in different orientations, and need to be padded accordingly).
Here is my workflow (screencap):

And, my crappy AppleScript:
on run {input, parameters}
set this_image to input
set target_H to 600
try
tell application "Image Events"
-- start the Image Events application
launch
-- extract the properties record
set the props_rec to the properties of this_image
-- get dimensions of the image
copy (dimensions of props_rec) to {W, H}
-- determine the shortest side and then
-- calculate the new length for the longer side
if W is greater than H then
set pad_dimensions to {W, 600}
set the scale_dimension to target_H
end if
-- perform action
pad this_image to dimensions pad_dimensions with pad color {255, 255, 255}
-- save the changes
save this_image with icon
-- perform action
scale this_image to size scale_dimension
-- save the changes
save this_image with icon
-- purge the open image data
close this_image
end tell
on error error_message
display dialog error_message
end try
return input
end run
I just want to continue making changes to the same image I started with in the automator workflow, but can't seem to keep going when I switch to AppleScript. Thanks in advance for your time/help!