2

I have layer1 with an image. And I have layer2 with a single solid color. Now I want to remove "something" (some color) via "some tool" from the whole image in layer1 (not just the background or some specific parts), so that the result of this action, put on top of the solid color layer2 and viewed together with it look like the original image.

Is this achievable (preferable in GIMP) and how? And is there a name to such an operation? I am not a graphics engineer and I am lacking even the vocabulary to sufficiently describe what I want. If I have a better word I also will change the title to something more apropriate.

Eg Object on a white background. Now, I don't want to remove just the white background and for that select the background manually or via "Select by color" or anyhow else. No, I want a single operation, that removes the white background and I don't mind if it also removes something from the foreground object as long as it, when I put it on top of a solid white layer, looks like the original image.

I tried "Color to Alpha" in GIMP but that did not work like I wanted it to. It seems to make the result in layer1 too transparent, so that when put on top of the solid white layer, both together look like a whitened version of the original.

7
  • 1
    I can't really see the purpose of this. Seems like you seek a shortcut for removing backgrounds. But if the resulting image only works on top of a certain background color and it looks exactly like before, what have you really achieved then? If you make all "white" (whatever that is - it's a matter of definition) transparent in an image and place it top of a light color, that color will tint the entire image.
    – Wolff
    Commented Oct 15, 2021 at 10:21
  • 2
    Show us a start point & an attempted result, so we can maybe see what it is you're trying to do.
    – Tetsujin
    Commented Oct 15, 2021 at 10:26
  • @Wolff: The purpose is to remove the surroundings in images, which are always white(-ish). The solid white color is not added back in the graphics program but in a webview via css. This gives me and the customer a lot more flexibility on how to display the forground object, as the result of the operation is the foreground object and its shadow only (minus the white color(s)). Now we are not bound anymore to the properties of the original images, eg their aspect ratio. I can programmatically also create collages of objects by moving them closer together than the originals would allow, etc. .. .
    – Creech
    Commented Oct 15, 2021 at 17:52
  • 1
    Sounds like color to alpha to me
    – joojaa
    Commented Oct 15, 2021 at 17:56
  • @Wolff 2: Hm ... the key is that the background color is not pure white, but white(-ish). If it was pure white, I could just cut the image to a rectangle around the foreground object and its shadow. But in the not ideal reality, the backgrounds have different shades and thus would have hard, noticable edges, when put on a pure white background or next to each other.
    – Creech
    Commented Oct 15, 2021 at 17:57

2 Answers 2

3

In Gimp 2.10:

  • Add a layer above, and set the blend mode to "Color Erase"
  • Fill with color to be erased

enter image description here

enter image description here

In the picture above:

  • The groups isn't technically needed, it is just there for demo purposes with its thumbnail displaying the result of the color erase
  • Toggling the "Color Erase" layer off doesn't change the result, which demonstrates that it removes exactly what the filler background layer will add back.
2
  • Thanks! I mark this as the answer as it does imo exactly what I was asking for. I tried it and it does. Also updating the title. Additional question: Is it possible to use a threshold when erasing a color, so not only that exact color gets erased, but also colors close to it?
    – Creech
    Commented Oct 15, 2021 at 17:41
  • That would be more or less what the "color-to-alpha in 2.10 does. But you wouldn't get the exact subtraction that would want.
    – xenoid
    Commented Oct 15, 2021 at 19:26
0

It would be better if you could share an image, because success may depend on the image itself, for example if it's a photograph or a graphic. All I can offer here is a bit of a guess.

  1. In GIMP, use color to alpha to remove all the white on the image.

  2. Put your white layer underneath. You will see the image looks washed-out

  3. Select the top image layer, and do a curves adjustment, and select the Alpha channel in the dropdown. Then you can make a curve to adjust the alpha so that the image looks less washed out when viewed against a white background.

Here's an example. I did this very quickly but if you have more time you could take more care to get the two images almost the same.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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