Setting Record Picture from Attachments

Has anyone ever been able to get a deluge script that takes an attachment from a record and then updates the record with that file?

I have a record that only gets one attachment (a profile picture in .jpeg format) that I’d like to automatically set as the record photo. Any idea how to do that?

Attachment is where I’ve gotten so far if I’m even on the right path!