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

Best way to semi-flatten a transparent gif against a background image

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.

4 of 4 messages available
Toggle history

Please log in to manage your subscriptions.

Best way to semi-flatten a transparent gif against a background image Justyn Butler 24 Sep 01:13
  Best way to semi-flatten a transparent gif against a background image David Gowers 24 Sep 03:03
   Best way to semi-flatten a transparent gif against a background image Justyn Butler 28 Sep 14:18
    Best way to semi-flatten a transparent gif against a background image David Gowers 28 Sep 16:38
Justyn Butler
2008-09-24 01:13:55 UTC (over 16 years ago)

Best way to semi-flatten a transparent gif against a background image

Hi,

I've been searching for the answer to this but I'm stumped. Maybe it's so obvious that there's no need for it to be covered in the docs, or perhaps I just don't know the correct terminology to search for.

If I have a png (like a button or logo) with anti-aliasing around the edge and an alpha channel and I need to convert it to a gif, I can use the semi-flatten option under Layer->Transparency. This will remove any semi-transparency while conserving anti-aliasing and the full-transparency of the image. To use this filter you have to know what color background will be behind the image when it is placed on the page.

With the semi-flatten tool you can only provide a solid color that the image will be placed over.
Normally this works fine, but I have a situation where the background behind the gif fades from light to dark and consequently semi-flattening against a solid color is not sufficient.

So what I want to do is semi-flatten against my known background image (a gradient, rather than a solid color) whilst preserving the fully-transparent parts of the gif.

I am very inexperienced with image software but I'm sure there must be a better way than I am doing right now, which is:

1) png with alpha channel in top layer 2) known background image in bottom layer 3) select non-fully-transparent part of image with Select By Color Tool (select alpha pixel then invert selection) 4) Flatten image
5) Copy selection
6) Paste As New

(Alpha to selection doesn't do the trick for step 3 because it discounts some semi-transparent pixels as well as transparent ones.)

It doesn't feel quite right - could someone with some more experience point out any unnecessary steps I'm taking or point out a better way altogether to do it please, if there is one?

Thank you, Justyn.

David Gowers
2008-09-24 03:03:44 UTC (over 16 years ago)

Best way to semi-flatten a transparent gif against a background image

Hi Justyn,

On Wed, Sep 24, 2008 at 8:43 AM, Justyn Butler wrote:

Hi,

I've been searching for the answer to this but I'm stumped. Maybe it's so obvious that there's no need for it to be covered in the docs, or perhaps I just don't know the correct terminology to search for.

If I have a png (like a button or logo) with anti-aliasing around the edge and an alpha channel and I need to convert it to a gif, I can use the semi-flatten option under Layer->Transparency. This will remove any semi-transparency while conserving anti-aliasing and the full-transparency of the image. To use this filter you have to know what color background will be behind the image when it is placed on the page.

With the semi-flatten tool you can only provide a solid color that the image will be placed over.
Normally this works fine, but I have a situation where the background behind the gif fades from light to dark and consequently semi-flattening against a solid color is not sufficient.

So what I want to do is semi-flatten against my known background image (a gradient, rather than a solid color) whilst preserving the fully-transparent parts of the gif.

I am very inexperienced with image software but I'm sure there must be a better way than I am doing right now, which is:

1) png with alpha channel in top layer 2) known background image in bottom layer 3) select non-fully-transparent part of image with Select By Color Tool (select alpha pixel then invert selection) 4) Flatten image
5) Copy selection
6) Paste As New

(Alpha to selection doesn't do the trick for step 3 because it discounts some semi-transparent pixels as well as transparent ones.)

I recommend:

1) Layer->Transparency->Threshold Alpha (to 1) 2) Alpha to selection
3) Copy Visible
4) Paste as New

David

Justyn Butler
2008-09-28 14:18:24 UTC (over 16 years ago)

Best way to semi-flatten a transparent gif against a background image

Thank you both for your tips.

I wasn't actually paying attention to the antialiasing/feather options so it is useful to know to keep them unchecked when performing this procedure.

To David: The steps you describe don't seem to help with my specific problem of flattening against a background image because Threshold Alpha seems to only work with a solid black background. Thanks anyway though.

cheers,
Justyn

2008/9/24 Francois du Toit :

I think your method is fine, just make sure antialiasing/feather is disabled for the select tool in step 3 ;)

2008/9/24 David Gowers :

Hi Justyn,

I recommend:

1) Layer->Transparency->Threshold Alpha (to 1) 2) Alpha to selection
3) Copy Visible
4) Paste as New

David

David Gowers
2008-09-28 16:38:07 UTC (over 16 years ago)

Best way to semi-flatten a transparent gif against a background image

On Sun, Sep 28, 2008 at 9:48 PM, Justyn Butler wrote:

Thank you both for your tips.

I wasn't actually paying attention to the antialiasing/feather options so it is useful to know to keep them unchecked when performing this procedure.

To David: The steps you describe don't seem to help with my specific problem of flattening against a background image because Threshold Alpha seems to only work with a solid black background.

Oops, what i said is impossible to perform correctly.. I've tried to find an alternate, and concluded that the best way to do this is by making a simple plugin that will do it in one keypress for you.

In the mean time, here is an alternative method which I've tested:

1) Alpha to selection 2) Activate Qmask mode (I normally bind a keyboard shortcut to this; if you mouse to it you activate it by clicking on the dotted red rectangle in the bottom left of an image window. 3) Threshold (1..255)
4) Exit qmask mode
5) 'Invert selection', 'Merge Visible', 'Edit->Clear'

And here is another alternative: 1) Add a layer mask, choose 'transfer alpha' 2) Copy Visible
3) Select layer content (ie. not layer mask), paste into it. 4) Select layer mask (ie. not layer content; the thumbnail that appears to the right of the normal layer content thumbnail), apply 'threshold' (1..255)
5) Delete background layer

I've tested that one too, and I think it may be faster than your current method.

David