Thursday 10 March 2022

How to edit PNG Alpha transparency levels (e.g. for a grub2 theme)

Recently I needed to edit some PNG files which were used in a grub2 theme (tutorial).

Many grub2 themes use a semi-transparent 'styled box' as a grey background on which the grub2 menu text entries are displayed.

In this example, menu_s.png, menu_sw.png and menu_se.png have been changed and so the bottom of the box is a slightly different colour and is opaque. You can see the clouds in the background wallpaper underneath the centre section.

Some themes draw a line across the bottom of the menu by making the top line of pixels in these three .png files a different colour - e.g. white...

The .png files seem to require 8-bit .png format (which is not the default in PhotoShop) and for transparency, you will need to adjust the Alpha-transparency value of the coloured object/pixel in each of the 9 files required by grub2 for a box...

The best online tool that I found which could adjust the Alpha values was at peko-step. This one was easy to use and had an advantage over some of the others in that it showed you the original Alpha value (A) of each object.


We will use Paint to fill with the colour we want, then we use peko-step to set the transparency value.

1. First use MS Paint to set the colour(s) that you want and re-save it as a .png file. These are saved as fully opaque (solid) colours.

2. Load the file into peko-step and click on the area that you want to adjust - note that the RGB and A=Alpha values should update on the browser page - this can take several seconds so you must wait a short while for this to happen.

File - Open Image

3. Now you can adjust the Alpha value. There seemed to be a 3-20 second delay in my browser before the Alpha value (A=153) was updated on the screen.

A fully opaque colour will have an A value of 255, whereas a value of A=0 will be completely transparent.

In the screenshot above, 60% of 255 = Alpha value of 153. You may need to use the Apply button and/or click the graphics object to get the new Alpha value to take affect.

4. Use File - Save image to re-save the  PNG file.

With the grub2 theme, I first adjusted and tested the menu_c.png file which is responsible for the large central portion of the  grey box and once the colour and transparency looked OK, I then changed the other eight grub2 file to the use same RGB colour and Alpha settings.

Note: I also tried LunaPic and OnLinePngTools but one did not show the Alpha level used in the original image and the other didn't seem to work but you may have better luck!

If you are familiar with gimp, you can use that instead.

No comments:

Post a Comment