Crop and save image from clipboard using GraphicConverter and AppleScript

I recently decided to start adding screenshots for our database layouts in our upcoming plug-in releases. To help automate this task, I build a script using GraphicConverter to deal with images copied to the clipboard. The script will save the cropped version and a thumbnail version in a folder called "screenshots" on the desktop. It will aslo add a title and a caption to the IPTC metadata.

Following is a cleaned up version of what I came up with.
--Open this script in a new Script Editor window.

property the_name : "from the clipboard" -- The file name
property the_title : "My clipboard" -- The title for IPTC
property the_caption : "This is my wonderful clipboard" -- The caption for IPTC

set destination_folder to (path to desktop as string) & "screenshots:"
tell application "Finder"
    try
        get destination_folder as alias
    on error
        make new folder at desktop with properties {name:"screenshots"}
    end try
end tell

tell application "GraphicConverter"
    activate
    new image from clipboard
    trim window 1
    
    tell window 1
        
        set IPTC objectname to the_title
        set IPTC caption to the_caption
        
        delay 1
        
        save in (destination_folder & the_name & ".jpg") as JPEG
        
        set s to image dimension
        set w to item 1 of s
        set h to item 2 of s
        
        set new_w to 200 / w
        set delta to (200 / w)
        set new_h to (h * delta) / h
        
        scale horizontal new_w vertical new_h --algorithm 1
        
        delay 1
        
        save in (destination_folder & "t_" & the_name & ".jpg") as JPEG
        
        set selection to {0, 0, w, h} -- "Select All"
        copy
    end tell
    
    close the front window saving no
    
end tell
...more entries
<- September 2010 ->
S M T W T F S

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30


Jesse.Traynham.com
π