Can a Mac app set the desktop image?

Been googling this and can't find anything.

Can an app set the Mac Desktop image? Like you create a fun cute image in the app, then it asks you 'Do you want to set this as your desktop image?' If you click yes it sets the image to be your desktop.

Can't find an SDK or API that would allow this.


Solution 1:

AppleScript is able to do this.

tell application "Finder" to set desktop picture to ((path to home folder as text) & {"Pictures:IMG_6860.jpg"}) as alias