Change the image size in a menu

Hello,

With Xcode:

In a menu, I display an image with the iconForFile method.
Is it possible to reduce the size of this image?


# For example:
set itemMenu to current application's NSMenuItem's alloc()'s init()

set theImage to current application's NSWorkspace's sharedWorkspace()'s iconForFile:"/Applications"
itemMenu's setImage_(theImage)

itemMenu's setTitle_("Applications")
itemMenu's setAction_("menubarApplications:")
itemsMenuBar's addItem_(itemMenu)
...


Thanks!

The documentation for the NSWorkspace’s ‘iconForFile:’ function, says the the returned NSImage is initially returned at 32 x 32 pixels, so as it’s an NSImage, you could change it with one of the NSImage’s function’s, like this.


set theImage to current application's NSWorkspace's sharedWorkspace()'s iconForFile:"/Applications"
theImage's setSize:(current application's NSMakeSize(16, 16)) --16 x 16 pixels

Regards Mark

Great!!

Thanks a lot Mark! :slight_smile: