How to get better transparency with GIFs?
Asked Answered
E

6

6

Is there any software, plugin or technique that would allow creating/exporting PNG-like GIFs with smooth transparent edges, at least for smaller images like bullets or buttons.

I really have to use GIFs sometimes for IE6 so it'd would be great to know if such a tool exists?

Thanks

Eudemon answered 23/12, 2009 at 11:58 Comment(0)
W
21

No, the GIF format does not support alpha-channel transparency like PNG does. You can only select one out of the 256 possible colors in a GIF to be transparent.

If you know roughly what color the background will be, the best you can do is create the GIF with the same background you plan to use it on, then select the background color as transparent. The smooth edges will look smooth against that specific background, but horrible against other colors.

Wardle answered 23/12, 2009 at 12:1 Comment(2)
However you can minimize the effects by carefully building up the GIF to reduce the ragged edges. You can also look for IE6 png fix.Envenom
Can't you use dithering to get fake partial transparency? That won't help with smooth edges but will help with shadows and thingsFortner
M
1

The edges in a PNG are smooth because of anti-aliasing, and thus, variable opacity. The GIF format doesn't support this, so unfortunately no there isn't a way to do it.

Maness answered 23/12, 2009 at 12:2 Comment(1)
Because of alpha information not being 0 or 1 but any value from 0 (transparent) to 255 (opaque), and not because of anti-aliasing.Resentment
D
1

GIF doesn't have an alpha channel like PNG, so you can't get smooth transparent edges. The alpha channel specifies how transparent each pixel is, so you could have half-transparent pixels for example. GIF on the other hand is limited to 8 bit colors and one of them is designated as the transparent color.

Debonair answered 23/12, 2009 at 12:2 Comment(0)
D
1

yes, a GIF can be transparent, just use png transparent frames and when embedded in css it would have a transparent background.

background: url(../images/mundog.gif) no-repeat;
Dialectician answered 21/8, 2018 at 13:10 Comment(0)
P
0

As far as I recall (I've not used GIFs for quite some time), a GIF doesn't have a variable transparency - a pixel is either transparent or not. You could simulate transparency by blending with the background image, but that would rely on having a static, defined background.

Palladino answered 23/12, 2009 at 12:2 Comment(0)
H
0

The modern solution for this is using WebP instead of GIF.
WebP supports both animation and an alpha channel, as well as lossless compression.
It's well-suported by browsers nowadays.

History answered 11/11, 2021 at 19:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.