Jim, there’s something you’re missing:
It’s not about using
initWithContentsOfFile which gets the content of an image file (png, tiff, jpg, icns…).
In this case, the icon placed on a file is perfect.
The problem is with
iconForFile that takes the icon resource as you could do by using the file info window in Finder (commad+i).
Try the first script I posted:
use framework "Foundation"
use framework "AppKit"
use scripting additions
set fromPosix to "/Users/ionah/Desktop/111/"
set toPosix to "/Users/ionah/Desktop/222/"
set imageData to (current application's NSWorkspace's sharedWorkspace's iconForFile:fromPosix)
(current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:toPosix options:0)
(current application's NSWorkspace's sharedWorkspace's noteFileSystemChanged:toPosix)
This is the kind of result I get with this script:
You said iconForFile uses a 32x32 pixels icon rendering.
The strange thing is that if the icon size is under 128 I get the result shown in the above screen capture.
But if icon size is set to a value > 128, I get this:
The icons are perfectly rendered!
(They are the same icons. It’s just the icon view preference that is changed).
Maybe this behavior is only on my Mac…