2

I need to have two 100% transparent colors (I mean invisible) black (000000) and white (ffffff).

When I try to have a 100% transparent color, gimp always set it to black (0x00000000 ARGB) even if I choose white.

Is-it possible to get something else than black transparent color with gimp ?
or I must use for example Alpha = 1 to get another color ? (<-- this works and it's fine, but for me 0% is better)

EDIT : How can I change transparent area color to another transparent color ?
For example from black alpha = 0 to white alpha = 0.

I guess this question seems to be weird, I have no knowledge in gimp or either in "graphic design" but I'm working on a software which need to know if transparent pixel is black or white (only for invisible pixels).

  • If the pixel is invisible, what difference does it make? – Scott May 11 '15 at 0:39
  • Why would a software system need to know if a transparent pixel is black or white? Also if you need that much control over "color", maybe use a text editor and write up an SVG graphic? – bemdesign May 11 '15 at 3:36
  • It's for efficiency, to make my code faster I merge some images and I need two colors to do it. I can transform what I need in white alpha = 0% with my own code, so I have the solution. I just wonder How I can do it with gimp (if it's possible) – Duffydake May 11 '15 at 8:19
  • Transparent pixels keep the colors they had - at least for an image that only ever has one single layer. This might be not feasible with your workflow - can you describe your process in a bit more detail? – Michael Schumacher May 11 '15 at 23:30
  • @Michael Schumacher You are right, I changed (programmatically) some areas color and gimp keep this color so "black" in my question is wrong. I tried to fill area with white and then "Color to alpha" and It works. Before I tried to do it with "bucket fill" and opacity to 0. There is maybe a better way to do it. Thanks, if you add an answer with this or either another approach I will accept it. – Duffydake May 12 '15 at 10:08
3

Ok, let's try to write an answer...

0. Some technical background

Many image file formats can actually preserve the color values of transparent pixels. PNG, TIFF, TGA, BMP are among them, as well as the working formats of most (or more likely all) serious image manipulation applications.

You can think of pixels as being colored and transparent according to a RGBA quadruple, with Red, Green, Blue and Alpha in a range of e.g. 0-255, 0.0-1.0, 00-FF or whatever is suitable (advanced user will notice that these examples are somewhat 8-bpc-centric)).

The A value being 0, usually meaning fully transparent, does not make the RGB values of the pixels useless per se, you might just not see them at the moment..

1. The building block

So let's take a basic PNG image with some colors and some transparency. The one here has been created by some solid noise clouds, mapped to a pastel full saturation gradient, and had the original solid noise clouds applied as it layer mask:

Solid noise, some colors and transparency

If you load this image in GIMP or a comparable application, and check the color values of the transparent (in your browser: background color, white for me) parts, you will notice that the RGB color values are intact. You can use the color picker tool for this.

As long as you stick to only one layer, you can apply tools like the eraser or procedures like layer masks to it - the colors or transparent pixels will be preserved. If you lock the transparency in the layers dialog, you can even use paint tools to change the color, without affecting the transparency.

What you can't do is use paint tools with opacity set to 0 - this won't have any effect.

2. How to fail

So this is nice and fine as long as you stick to one layer. But what if you want to do more, for example add more layers, e.g. some text? Well, usev the text told to do just this, export as PNG and get:

Add a layer and you FAIL - invisible black

Get the image above loaded in GIMP and examine the transparent parts, and you'll see what happened. Looks ok, but this is one of the easiest ways to fail.

Add a layer, and the transparent parts will be invisible black if you merge the layers into one - something that is done in the file export plug-ins, for example. A somewhat arbitrary technical decision, but so far no one has changed it yet. And changing it in a way that make the results predictable might be some kind of challenge.

3. How to succeed

There is a workaround for this, however. The one method to preserve the image as-is is copy/cut&paste - somewhat logical, because you do not want to copy or cut a part of an image, paste it somewhere else and find some arbitrary image data altered, except the parts where you cut from and where you paste, of course.

So, if you have added a text layer, you can cut it from the image, paste it immediately, and then anchor it to the one layer you image is supposed to have. Examine the resulting image below, you will find that the transparent parts have retained their color data:

Copy or cut, paste and anchor and keep your transparent color data

This workflow requires some planning and time, of course - you might find yourself setting the image up as a proper XCF file with multiple layers first and save it so, and then copy the layers over into a new, temporary file one by one, anchoring them in the proper order after each paste. But you will preserve the color data of transparent pixels this way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.