Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding/Editing transparency in an indexed PNG
#1
Hello,

I have an indexed PNG and want to edit the transparency of it - my problem: Transparency is either 0% or 100%

What I'd like to have: I'd like to add a transparency value to each of the 255 indexed colours - so colour 1 is totally transparent, and the others transparency should be set to something between 50% and 90% depending on their brightness (white -> 90%, black -> 50% or something similar) - (I wouldn't mind to edit the 255 colours by hand if necessary).

I did something like this few years ago, but can't reconstruct how I did it - though I ended up with a 24 bit per Pixel PNG, so maybe it's not possible to have an indexed PNG with varying degrees of transparency!?

If I open the indexed PNG it shows two channels, one with the image information and the other with transparency information is a black or transparent thing with nothing inbetween (seems to be just 1 bit of info per pixel) - so maybe it's possible to change that part (and have 1 byte per pixel as well).

Thanks for any hints.
Reply
#2
Indexed mode in Gimp is really for GIF and has the GIF restriction that transparency is an all-or-nothing concept. and as as far as I can tell the color indexing in PNG is RGB colors, the alpha channel isn't part of the indexing.
Reply
#3
As far as I know transparency in an indexed image, is on or off as previously stated and not possible to edit from the Gimp indexed colormap. You can get a simulation of semi-transparency using dithering but only when the image is originally RGB mode -> Indexed

This a simplified image with two of the bands with semi-transprency from RGB mode.

The indexed image:

   
Reply
#4
(11-19-2022, 09:42 AM)rich2005 Wrote: As far as I know transparency in an indexed image, is on or off as previously stated and not possible to edit from the Gimp indexed colormap. You can get a simulation of semi-transparency using dithering but only when the image is originally RGB mode -> Indexed

This a simplified image with two of the bands with semi-transprency from RGB mode.

The indexed image:

Hi, thanks, dithering is not really an option for the map overlay thing that I'm creating - I guess I'll manage somehow to convert the original indexed thing to RGB, using the same image converted to grayscale, adjusting the curve, so it's going mainly from 60 to 90%. Somehow combining the layers with multiply to get the transparency of wanted value. When I save that as PNG, it will be 24 bit and about 3 times the size of the original (as it was when I did something similar some years ago), but it will have the transparency I need. And I guess it was about what I did back then.

If there's some other method that doesn't blow up the size by a factor of three, it would be fine, but seems to be difficult or next to impossible.
Reply


Forum Jump: