-- This script should be run as a droplet
-- It expects that an image is dropped on it's icon
-- The on run handler is called if the user has double clicked the icon
display dialog "Please drop an image file on this Icon to set it as the desktop background"
-- The on open handler is called when the user drags and drops afile on the icon
on open draggeditems
set imageFile to last item of draggeditems
tell application "Finder"
select window of desktop
set desktop picture to file (imageFile as text)
display dialog "Invalid image file."