I wrote a command line tool which can get either the file icon or the QuickLook preview image of a file. It’s 10.5 or later only. You can download it from here:
http://www.hamsoftengineering.com/codeSharing/qlpreview/qlpreview.html
I wrote this in response to helping someone in these forums. You can see that thread here. The command line tool can be run from applescript. Here’s an example script…
-- Example usuage of qlpreview to get a QuickLook preview of a file
-- qlpreview will output an image file of the preview as seen in QuickLook
-- if the QuickLook preview cannot be found then the normal file icon is output instead
-- variables
-- Note: all variables need to be strings
set exePath to (path to desktop folder as text) & "qlpreview" --> path to the unix executable qlpreview
set imageType to "jpg" --> jpg, png, or tif
set width to "1000" --> the width in pixels of the preview image
set height to "1000" --> the height in pixels of the preview image
set asIcon to "yes" --> do you want a pretty icon format?
set outPath to (path to desktop folder as text) & "test" -- where you want the image saved
set preferFileIcon to "no" -- when yes the file icon is returned even if the preview image exists
-- get the file you want the preview image of
set inPath to choose file without invisibles
-- setup the shell command
set cmd to quoted form of POSIX path of exePath & space & "-imageType" & space & imageType & space & "-width" & space & width & space & "-height" & space & height & space & "-asIcon" & space & asIcon & space & "-inPath" & space & quoted form of POSIX path of inPath & space & "-outPath" & space & quoted form of POSIX path of outPath & space & "-preferFileIcon" & space & preferFileIcon
-- run it!
try
do shell script cmd
on error theError number errorNumber
if errorNumber is not -128 then
tell me
activate
display dialog "There was an error:" & return & return & theError & return & return & "Error Number: " & errorNumber as text buttons {"OK"} default button 1 with icon stop
end tell
end if
end try