moses-palmer / pystray

GNU General Public License v3.0
479 stars 59 forks source link

Blurry icons on MacOS #163

Open andreypolyak opened 7 months ago

andreypolyak commented 7 months ago

Hi, thanks for the lib!

I have a problem with setting up high-quality retina icons on MacOS.

I think it happens because of this code: https://github.com/moses-palmer/pystray/blob/1907f8681d6d421517c63d94f425f9cdd74d0034/lib/pystray/_darwin.py#L166-L174

On my laptop (13" MacBook Air M1), self._status_bar.thickness() is 22px. So, to make it retina-quality (2x), I need to pass an icon with a 44x44px resolution. But then the code above resizes it back to 22x22px, and the icon becomes blurry.

Would be great to have some way to pass high-quality retina icons!

simonrob commented 3 months ago

I worked around this (and added various other functionality) here in case it helps.

moses-palmer commented 4 weeks ago

Thank you for your report and suggestions!

I have incorporated some of your changes in fixup/general. @andreypolyak, does this resolve your issue?

scosman commented 2 weeks ago

haha, I figured all of this out yesterday, only to find your branch today. 🤦

@moses-palmer I think there's still one issue. Since you resize the image before loading the NSImage, it will still be blurry, as the image resolution is too small. The size is in "points" on a Mac, not pixels. The image should have at least 3x more pixels than the points for high resolution displays.

I took a stab at the fix here: https://github.com/moses-palmer/pystray/pull/176 . The alternative is don't do any image resizing on Mac, just set the size, and let NSImage handle it (which it can).