There are similar answers already on here (like this one), but not with exactly what I want to accomplish. I would like to create an AppleScript that takes a chosen folder and application (or image file), scales the icon of the application/image down to maybe 60% of normal, layers that scaled icon onto the folder icon in a chosen position, and then pastes the resulting layered icon back onto the chosen folder. For example, something like this.
I've been working based on the other solution I linked to, but I don't know much AppleScript, and I don't know enough about Foundation and AppKit to even begin with that. What I've tried so far with plain AppleScript hasn't worked, and I'm not sure I can even accomplish what I want with plain AppleScript (particularly the layering part, I believe). Any help greatly appreciated.
In addition to image editing applications such as Gimp, there are a variety of applications available that will overlay an image onto a folder. If you just wanted to use a script to do it yourself, AppleScriptObjC can be used to access methods from various Cocoa classes such as NSImage.
The following script gets a generic folder icon image from the system resources and an overlay image from a file or application icon. The image is then scaled and composited onto the folder image and set as the icon for a folder or saved to a file on the desktop. Note that the Finder mostly creates its own composite icons, so they may be different than the system defaults.
A folder icon can be set programmatically, but I have found that the scale and location offsets of the application icons usually need to be adjusted a little, as the overlay image may have different padding or arrangement within its bounds. An image file can also be dragged to a Finder Get Info window to set the icon, so the default is to save the output image to a file.