tray icons usage Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
marypoppins_1
Posts: 123
Joined: 28 Oct 2020, 02:58

tray icons usage

Post by marypoppins_1 » 09 May 2024, 01:09

hello. i was reaading on the usage of tray icons in ahk v2 but some things remain unclear to me.
1. it seems as though the .ico format is most desired. does it have any advantages??
2. are there recommendations for icon size / resolution ??
3. is it possible to, say, put a rectangular icon and have it be displayed as a rectangle ?? (because most icons seem to have filled an area in a square)
thanks in advance

User avatar
mikeyww
Posts: 27169
Joined: 09 Sep 2014, 18:38

Re: tray icons usage

Post by mikeyww » 09 May 2024, 06:02

Hello,

These seem to be questions about how Windows uses icons, rather than anything to do with AHK. I'm not an icon expert but can offer the following comments. Icon files use a specialized format that may contain not just one image but a set of related images of various sizes, integrated into a single file. Although an icon file need not always have multiple images, advantages may occur.
  1. A "best fit" may be selected for the display's resolution or the specific use of the icon.
  2. Other images in the file may be used in other circumstances. These may be similar or different.
  3. The icon file may accommodate programs that require a specific image size.
The OS, program, etc. can then use a size that fits the situation most closely. The images are usually square by convention. The image widths that are actually used most often are probably 24, 32, and 48 pixels, but additional sizes can be used.

If you work with an icon editor, you can quickly see all of these options and get your icon ready to use.

User avatar
boiler
Posts: 17189
Joined: 21 Dec 2014, 02:44

Re: tray icons usage  Topic is solved

Post by boiler » 09 May 2024, 06:08

My thoughts:
marypoppins_1 wrote: 1. it seems as though the .ico format is most desired. does it have any advantages??
From the TraySetIcon documentation:
Slight distortion may occur when loading tray icons from file types other than .ICO. This is especially true for 16x16 icons. To prevent this, store the desired tray icon inside a .ICO file.

marypoppins_1 wrote: 2. are there recommendations for icon size / resolution ??
16x16 to be used without distorting the image. Larger images would lose their sharpness to be made to fit in the space.

marypoppins_1 wrote: 3. is it possible to, say, put a rectangular icon and have it be displayed as a rectangle ?? (because most icons seem to have filled an area in a square)
thanks in advance
Not sure what you mean by “seem to have filled an area in a square”. I don’t believe it would change the aspect ratio to fill the square in both directions. I think it would leave it in your rectangular shape but just leave one of the dimensions unfilled. For example, if you had an image that was 16 pixels high and 32 pixels wide, I believe you are hoping it would fill the 16-pixel height and just make it take up 32 pixels horizontally. But it won’t make have it take up more than the allocated space in the tray for an icon, so I think it would shrink it by 50% in both directions so it would be 16 pixels wide and only take up 8 pixels of height (4 empty rows of pixels above and below it in the allocated space).

marypoppins_1
Posts: 123
Joined: 28 Oct 2020, 02:58

Re: tray icons usage

Post by marypoppins_1 » 09 May 2024, 07:02

okay, thank you mikey and boiler

User avatar
kunkel321
Posts: 1127
Joined: 30 Nov 2015, 21:19

Re: tray icons usage

Post by kunkel321 » 09 May 2024, 07:54

Another argument for using .ICO files is that, if your script has any GUIs that appear, Windows will apply your custom icon to the GUI as well. The icon in the top corner will also be 16x16, but probably an icon will appear in the Windows Taskbar at the bottom, while the GUI window is open. The Taskbar image will likely be 32x32. I'm also not a Windows expert, but I make some of my own icons. Here is a recent one I did. I made the high-rez one, then converted it to ICO format. The conversion process automatically creates the different sizes, but the smaller ones are all blurry and terrible. So I edited the 16x16 one after conversion to give it crisp edges. It makes it look nicer in the System Tray.

Image

And as Boiler indicated, if I wanted this to be a rectangle, I'd keep the same aspect ratio (square) but just "erase" the pixels on the top and bottom. (Or on the sides, for a tall rectangle.)
ste(phen|ve) kunkel

marypoppins_1
Posts: 123
Joined: 28 Oct 2020, 02:58

Re: tray icons usage

Post by marypoppins_1 » 09 May 2024, 08:28

yeah okay thank you. i'm currently working on making my own icons too but in svg then i can make them any size without losing quality and convert to .ico

User avatar
kunkel321
Posts: 1127
Joined: 30 Nov 2015, 21:19

Re: tray icons usage

Post by kunkel321 » 09 May 2024, 11:32

marypoppins_1 wrote:
09 May 2024, 08:28
yeah okay thank you. i'm currently working on making my own icons too but in svg then i can make them any size without losing quality and convert to .ico
Yeah, I always make mine as SVGs too. Converting them to ICO always "rasterizes" them though.
ste(phen|ve) kunkel

marypoppins_1
Posts: 123
Joined: 28 Oct 2020, 02:58

Re: tray icons usage

Post by marypoppins_1 » 09 May 2024, 11:34

what do you mean? after making them in svg, i scale them to let's say 256x256 png then convert png to ico. and pretty sure then windows downscales it to 16x16 or whatever scale it needs for the taskbar. works for me

User avatar
kunkel321
Posts: 1127
Joined: 30 Nov 2015, 21:19

Re: tray icons usage

Post by kunkel321 » 09 May 2024, 12:00

marypoppins_1 wrote:
09 May 2024, 11:34
what do you mean? after making them in svg, i scale them to let's say 256x256 png then convert png to ico. and pretty sure then windows downscales it to 16x16 or whatever scale it needs for the taskbar. works for me
Yep -- Again, same here. I think the downscaling that Windows does is probably the same procedure that most icon-conversion tools use. Personally, I find that the antialiasing makes most of my images blurry when they are reduced in size, especially if the larger image was very detailed. That's just my own experience though.
ste(phen|ve) kunkel

User avatar
boiler
Posts: 17189
Joined: 21 Dec 2014, 02:44

Re: tray icons usage

Post by boiler » 09 May 2024, 12:34

I agree that a .ico file that contains various size images drawn specifically for that size looks much better than letting Windows scale up or down based on one size.

Post Reply

Return to “Ask for Help (v2)”