RSS/Atom feed Twitter
Site is read-only, email is disabled

Having trouble creating transparent background

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

6 of 6 messages available
Toggle history

Please log in to manage your subscriptions.

Having trouble creating transparent background Accordeoniste 31 Jan 23:33
  Having trouble creating transparent background Steve Kinney 01 Feb 01:10
   Having trouble creating transparent background Accordeoniste 02 Feb 18:17
    Having trouble creating transparent background Steve Kinney 04 Feb 06:56
     Having trouble creating transparent background Accordeoniste 05 Feb 20:16
  CORRECTION Steve Kinney 01 Feb 01:16
2017-01-31 23:33:04 UTC (almost 8 years ago)
postings
3

Having trouble creating transparent background

I took a photo of me standing against a wall. The wall is pale yellow in color. It's hard to describe its texture, but it isn't smooth, if that makes a difference.

To create a transparent background, I took the advice of an online tutorial. First I added an alpha channel with Layer / Transparency / Add Alpha Channel. Then I selected the background with the Fuzzy Select tool. Then I pressed the delete key. The result was a mostly transparent background. There's a moving black and white line that borders my image. There are also moving black-and-white striped areas near my arm, and random white spots that sparkle. I tried using the eraser tool to remove the black-and white patches, lines and spots, but after erasing them, they re-appeared. Another time I followed this procedure, the white areas were either more pronounced or there were orange-brown streaks bordering my photo.

Is there a way I can efficiently remove the white debris in GIMP, whatever it's from, so the background is completely transparent, without having to take another photo of myself against a different background, e.g. a white one? It's important that I get this right as I want to place my photo against a more dramatic background image to display on my website. I'd be grateful for any suggestions.

Steve Kinney
2017-02-01 01:10:40 UTC (almost 8 years ago)

Having trouble creating transparent background

On 01/31/2017 06:33 PM, Accordeoniste wrote:

I took a photo of me standing against a wall. The wall is pale yellow in color. It's hard to describe its texture, but it isn't smooth, if that makes a difference.

To create a transparent background, I took the advice of an online tutorial. First I added an alpha channel with Layer / Transparency / Add Alpha Channel. Then I selected the background with the Fuzzy Select tool. Then I pressed the delete key. The result was a mostly transparent background. There's a moving black and white line that borders my image. There are also moving black-and-white striped areas near my arm, and random white spots that sparkle. I tried using the eraser tool to remove the black-and white patches, lines and spots, but after erasing them, they re-appeared. Another time I followed this procedure, the white areas were either more pronounced or there were orange-brown streaks bordering my photo.

Is there a way I can efficiently remove the white debris in GIMP, whatever it's from, so the background is completely transparent, without having to take another photo of myself against a different background, e.g. a white one? It's important that I get this right as I want to place my photo against a more dramatic background image to display on my website. I'd be grateful for any suggestions.

No problem. There is no one-step push button method; cleanly separating an object in a photograph from its background always takes some tweaking. But we have ways:

https://www.youtube.com/watch?v=xEfRVEC2cmY

True confession: I almost started to write instructions before I thought to look for a video tutorial.

Handy household hint: While painting bits of your foreground object in and out of visibility, you can quickly switch from white to black by putting the brush over a visible or transparent part of your image in progress, hold down the Alt key, and click once. That will set the brush color to whatever was under the center of the brush when you clicked on the canvas.

All done? Crop your image with the Crop tool, save it as an XCF file so you can make modifications later if desired, scale it to suit and Export to PNG. Viola. (I would take care not so Save the scaled version as XCF, which would over-write and destroy the original scale image you worked on.)

:o)

Steve Kinney
2017-02-01 01:16:26 UTC (almost 8 years ago)

CORRECTION

Oops.

Correction: I said hold down the Alt key to pick a color off your layer with a paintbrush. That's wrong. Use the Ctrl key. Silly me. In real life I do it by reflex, but when typing...

Also: You can play "connect the dots" with any brush tool, by holding down the Shift key (yes, that's the right one) to draw a straight line from the end of your last brush stroke to the center of the current brush position with a click. I find this /very/ helpful when following curves and such.

:o)

2017-02-02 18:17:45 UTC (almost 8 years ago)
postings
3

Having trouble creating transparent background

Hello Steve,

Thanks for your suggestions. I did as you suggested and I'm pleased with the result. It was a painstaking process, though. I had to enlarge the image, sometimes to 400%, to be able to see it clearly enough to make the necessary changes. Editing the background was delicate work as I had to be careful not to make the photo transparent. There was much trial and error involved. There's still a very slight bit of jaggedness on the perimeter of the photo, but fortunately it's not so noticeable at magnifications less than 50%. Also, fortunately, any imperfections in the exported image (including those I didn't eliminate in the photo itself that I considered minor, although I may go back and do that later) should become more insignificant once I place my photo on the background photo I mentioned.

Incidentally, I previously tried that approach, adding a layer mask, that is. I had found the YouTube video you referred to. That time, though, I thought the approach failed because after the first attempt, there were spots and faint lines on the background, even thought I thought the whole background was transparent. After that first attempt I gave up. This time I was careful to paint over the blemishes and I eventually eliminated them.

Perhaps you can help me with this too. What are your thoughts about blurring the background image after I place my photo over it? Will it enhance or detract from the combined image? I ask this because I based my photo theme on a Wordpress template when I took my photo, and the template photo features a model against a blurred background of office buildings. The model stands out distinctly in the photo, and it looks very professional.

Gary Krupa

No problem. There is no one-step push button method; cleanly separating
an object in a photograph from its background always takes some tweaking. But we have ways:

https://www.youtube.com/watch?v=xEfRVEC2cmY

True confession: I almost started to write instructions before I thought to look for a video tutorial.

Handy household hint: While painting bits of your foreground object in
and out of visibility, you can quickly switch from white to black by putting the brush over a visible or transparent part of your image in progress, hold down the Alt key, and click once. That will set the brush color to whatever was under the center of the brush when you clicked on the canvas.

All done? Crop your image with the Crop tool, save it as an XCF file so
you can make modifications later if desired, scale it to suit and Export
to PNG. Viola. (I would take care not so Save the scaled version as XCF, which would over-write and destroy the original scale image you worked on.)

:o)

Steve Kinney
2017-02-04 06:56:28 UTC (almost 8 years ago)

Having trouble creating transparent background

On 02/02/2017 01:17 PM, Accordeoniste wrote:

Hello Steve,

Thanks for your suggestions. I did as you suggested and I'm pleased with the result. It was a painstaking process, though. I had to enlarge the image, sometimes to 400%, to be able to see it clearly enough to make the necessary changes. Editing the background was delicate work as I had to be careful not to make the photo transparent. There was much trial and error involved. There's still a very slight bit of jaggedness on the perimeter of the photo, but fortunately it's not so noticeable at magnifications less than 50%. Also, fortunately, any imperfections in the exported image (including those I didn't eliminate in the photo itself that I considered minor, although I may go back and do that later) should become more insignificant once I place my photo on the background photo I mentioned.

Yay!

Here's something that might be interesting to try: Make a copy of your masked layer, turn off visibility of the original layer (click the eyeball icon in the Layers dialog), and click the mask on the visible copy to make it the active selection. Then, blur the mask and check the visible result. A few pixels of blurring might give a more realistic blending with the background. As always, Control+z (undo) is your friend, try a couple of different values - maybe just 2 or 3 pixels, maybe more - and see what happens.

Perhaps you can help me with this too. What are your thoughts about blurring the background image after I place my photo over it? Will it enhance or detract from the combined image? I ask this because I based my photo theme on a Wordpress template when I took my photo, and the template photo features a model against a blurred background of office buildings. The model stands out distinctly in the photo, and it looks very professional.

Ah yes - this technique is often used to make a foreground object stand out in a picture. It simulates a sharp focus on the foreground object with a relatively flat depth of field. Don't overdo the blur if you want a "realistic" looking result though.

Another way to make the foreground stand out is to slightly reduce the saturation and contrast of the background, again careful not to overdo it unless you want the finished product to look manipulated, vs. just a little extra eye-catching.

Yet another method - a favorite of mine - is a vignette. Put a new layer over your background, give it a layer mask, and use the Ellipse Selection tool to draw an ellipse around the foreground object, with its edges maybe halfway or so between the outline of the foreground object and the edges of the image as a whole. Do Select > Feather and pick a big value - maybe about half the distance from the edge of the ellipse to the foreground object. This will, in effect, "blur" your selection. Then drag and drop black from your color selector to the image canvas with the mask selected in the Layers dialog. This will make your new layer transparent in the area including your foreground image. Then select the image component of the layer in the Layers dialog, drag and drop black to the image canvas, and viola: The result is your foreground object visible in an oval surrounded by black. Finally, in the Layers dialog, use the transparency slider to turn the visibility of your new layer WAY down. Adjust until the effect of the vignette layer on the visible image is barely noticeable. Viola, all eyes on the foreground object.

Some combination of the above methods should give you results you like. Again, don't overdo it unless you want a "bold" a.k.a. unnatural looking result. The beauty part: You can come back later and, if you don't like the result after a break from looking at it, open up the XCF file and make any changes needed - you still have all the original parts of the un-messed-with image available to play with.

:o)

2017-02-05 20:16:04 UTC (almost 8 years ago)
postings
3

Having trouble creating transparent background

Yay!

Here's something that might be interesting to try: Make a copy of your
masked layer, turn off visibility of the original layer (click the eyeball icon in the Layers dialog), and click the mask on the visible copy to make it the active selection. Then, blur the mask and check the
visible result. A few pixels of blurring might give a more realistic blending with the background. As always, Control+z (undo) is your friend, try a couple of different values - maybe just 2 or 3 pixels, maybe more - and see what happens.
Ah yes - this technique is often used to make a foreground object stand
out in a picture. It simulates a sharp focus on the foreground object with a relatively flat depth of field. Don't overdo the blur if you want a "realistic" looking result though.

Another way to make the foreground stand out is to slightly reduce the saturation and contrast of the background, again careful not to overdo it unless you want the finished product to look manipulated, vs. just a
little extra eye-catching.

Yet another method - a favorite of mine - is a vignette. Put a new layer over your background, give it a layer mask, and use the Ellipse Selection tool to draw an ellipse around the foreground object, with its
edges maybe halfway or so between the outline of the foreground object and the edges of the image as a whole. Do Select > Feather and pick a big value - maybe about half the distance from the edge of the ellipse to the foreground object. This will, in effect, "blur" your selection.
Then drag and drop black from your color selector to the image canvas with the mask selected in the Layers dialog. This will make your new layer transparent in the area including your foreground image. Then select the image component of the layer in the Layers dialog, drag and drop black to the image canvas, and viola: The result is your foreground object visible in an oval surrounded by black. Finally, in the Layers dialog, use the transparency slider to turn the visibility of
your new layer WAY down. Adjust until the effect of the vignette layer
on the visible image is barely noticeable. Viola, all eyes on the foreground object.

Some combination of the above methods should give you results you like.
Again, don't overdo it unless you want a "bold" a.k.a. unnatural looking
result. The beauty part: You can come back later and, if you don't like the result after a break from looking at it, open up the XCF file and make any changes needed - you still have all the original parts of the un-messed-with image available to play with.

:o)

Hi Steve,

I'm satisfied with my photo as it is with a transparent background. Later on, when I have more time, I'd like to try out your suggestions for a more eye-catching look. Thanks very much for those new suggestions, though! For now i have something else in mind I'd like your help with. I don't know how much you know about HTML, but since I want the photo to appear on my website, this may require manipulation of the HTML code on the site. I wrote much of the code myself.

Since I last updated this thread, I superimposed my photo with the transparent background onto another image in the background. To give you a better idea of what's involved, I'll tell you that the background image is a picture of the Golden Gate Bridge in San Francisco. To make the bridge appear longer, I changed its scale so that the width is 2 1/3 X the height, instead of 1 1/3 x the height as it was originally. Then I added some text to the combined image. I didn't create another layer for my photo, only for the text.

When I inserted the name of this file in my index.html file in the header section, the combined image I created either looked distorted, or didn't fit properly in the header space. Sometimes it was out of alignment with the other header image, sometimes it didn't fill the remaining header space. I tried different CSS and html combinations with varying widths and heights, and nothing I tried caused the image to come out just right. When I created the combined image with the bridge at its original scale, inserted it in the header and increased only the width in my html file, the bridge looked okay but my own image looked out of proportion.
I thought of simply enlarging the Golden Gate Bridge image using the original scale, that would make the bridge appear longer, but then I'd have to increase the height of the header space. That won't do because the other header image is an animated image that I don't know how to resize. Anyway, I want a balanced look with the header composition, and even if the animated image is resized, the header would appear unbalanced, I suspect.

Until I find a way to insert the combined image in my header, as it appears in GIMP, so that it fits properly in the space, I'm using a version of the image with the Bridge photo in its original scale. The text appears next to the photo instead of on it. The view isn't as dramatic as it would be with the re-scaled bridge photo, I admit, but at least it looks well-organized and interesting. If you want to see it, I'll send you both PNG files created in GIMP, since I haven't uploaded the modified HTML file and images to my website yet.

If this would take up too much of your time to assist with in this forum, just tell me, or don't reply. I'll completely understand. It occurred to me that you may have dealt with this problem before and you might be able to recommend a good solution without going to much trouble, so I thought it wouldn't hurt to ask you about it.

Gary