Photoshop CS and Scripting

I just discovered that Photoshop CS supports scripting in AppleScript, JavaScript and Visual Basic!  There's a complete type library available for the Visual Basic developer, and you can use either VBScript or full blown Visual Basic.  I'm going to bet that I can also use Visual Studio .NET.  For more information on scripting Photoshop CS, check out the reference documentation in C:\Program Files\Adobe\Photoshop CS\Scripting Guide.

This will solve a challenge I've been having with Photoshop of late.  We gave my grandmother a Ceiva digital picture frame which wants images to fit within 640x480.  The problem this creates for me is automating the resize depeding if your orientation is landscape or portrait.  With landscape images, you want to resize the width to be 640 pixels, while with portrait images you want to resize the height to be 480 pixels.  Photoshop's Actions can't handle this because they don't support conditional logic.  With scripting, howerver, this should be a very straight forward thing to do.

Off to write a script ...