How to get the tray icon scale correctly in macos electron?
Asked Answered
G

3

7

I've tried 32x32, 64x64, and I've tried to use Photoshop to edit another app's icon into my icon to keep its size but it never works with me. It seems that my icon is double-sized and I can't get the whole icon to be visible.

Glasswort answered 16/6, 2018 at 6:44 Comment(0)
P
12

You can append @2x after image's base filename to mark it as a high resolution image.

This was helpful for me: https://www.electronjs.org/docs/api/native-image#high-resolution-image

Phlebotomize answered 30/3, 2020 at 22:5 Comment(0)
F
7
  const image = nativeImage.createFromPath(
    path.join(__dirname, "your-path/icon.png")
  );
  tray = new Tray(image.resize({ width: 16, height: 16 }));
Filmdom answered 16/4, 2021 at 6:38 Comment(0)
B
5

16x16 png will work fine for Macos tray icon. You can also have @2x 32x32 png for high-resolution displays, e.g. 16x16 'tray.png' and 32x32 '[email protected]'.

Broaden answered 29/11, 2018 at 9:51 Comment(1)
Yeah possibly because that API is deprecated now, electronjs.org/docs/api/breaking-changes#tray. I'll remove that link for clarity.Broaden

© 2022 - 2024 — McMap. All rights reserved.