Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When indexing (a png), how do I select the transparent color?

Status
Not open for further replies.

Unislash

Technical User
Jun 23, 2007
2
US
I'm creating images for an online game, which requires them to be a .png as well as indexed with a transparent background. The problem that we have been having is that when we index the transparent pngs, the gimp chooses a color that has been used in the image to represent the transparent background. As a result, when displayed in our client (the game), the pixels that have the same color as the transparent background and are supposed to be displayed... are not.

We have figured that if we use the traditional pink color (%100 red, 0% green, %100 blue) for the transparent background, this won't happen (or it'll happen extremely rarely--who uses that color in their artwork? :p). Thus, my question:

When indexing (a png), how do I select the transparent color?
____________

Also, because I am doing this to a couple hundred images (>1000, I'm sure), I tried to develop a script using script-fu. With me being a really, really bad programmer, it never happened :p. If anyone could make a script that I can run to somehow automate this process (at least a little), I would be very grateful.

I was thinking something like... I open all of the files, I run the script, then all I need to do is select (by color) the background of each file to be transparent (maybe it would be better if I selected before running the script?). The script would then clear that selection, index the image (using default values), and save it. Perhaps another script that I could run before this would assure that all of the images have an alpha layer?

I would be awesome if I that, and would take hours off of my workload.

Thanks, all :)

Cheers,
Unislash
 
It works for me, using GIMP 2.2.13 on Linux. I create an image with a transparent background, change its mode to indexed, save it as PNG, display it in a browser with any colour background, and the transparent bits works as expected.

I've never used Script-fu, so can't help there. I use ImageMagick utilities for that sort of automated processing of images.
 
Sorry for the late reply here :/

Anyway, i've continued my search, but no success :(. Maybe someone will see this and know exactly what to do (I can hope, can't I?)

TonyGroves: Well, the transparency generally works, but I'd like to know how to pick the color that represents the transparency.

Say you open a transparent image in MS Paint. You'll find that your transparent parts have now become a (somewhat random, but dark) color. How would i make Gimp pick a certain color instead of random-ish? I'd even be content to know how The Gimp chooses this color (then i could investigate myself).


Anyone have ideas?

Cheers,
Unislash
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top