Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

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 :)


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

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.

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

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?


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close