• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Home
  • About
  • My Blogs
    • Photoblog
    • Knots
    • WP.com tips
kristarella.com

kristarella.com

Happiness Engineer at Automattic, lover of knitting, crochet, sci-fi and more

  • Presentations
  • Plugins
    • Exifography
  • Contact
You are here: Home / Design / Graphics / Transparency and GIFs

Transparency and GIFs

10 September 2007 by kristarella

How the heck do you get nice edges in GIFs with transparent backgrounds? I’ve been pondering this for sometime and I think I finally have the answer! It’s deceptively simple and I expect others have probably been doing this for some time.

First some background

Graphics Interchange Format or GIF (supposedly pronounced jif, but I’ve never heard that used) is a widely supported graphics format. It’s been used widely on websites because it’s supported, it has transparency and animation capabilities and lossless compression (reducing file size without reducing quality). GIFs are best used for image with solid areas of colour, like logos, rather than photos. It only supports 8-bit colour (256 different colours), whereas JPEGs can save information for 16 million colours (but have lossy compression).

I have preferred to use PNGs because they support 24-bit colour and alpha transparency. GIFs don’t support alpha transparency, which means that one pixel either has colour or it doesn’t. Whereas PNGs can have opaque or transparent colour in one pixel, making the edges around shapes softer (among other things).

PNG vs GIF - tranparency comparison

Compare the image of text above, the left side was saved as a PNG and the right side was saved as a GIF (I’ve merged them both into a final PNG format, but that doesn’t make a difference after the GIF has already been indexed etc). Sadly, Internet Explorer 6 (which about 20% of you guys still use) doesn’t support transparency in PNGs so GIFs remain the primary graphic for webpage background images and the like.

So how do you stop the skanky edges?

  1. Make sure you’re working in RGB or grayscale mode, not indexed.
  2. RGB mode

  3. Create your logo or text in one transparent layer.
  4. Make another layer behind your logo with the colour that the logo is going to be on (if your logo is going to be on top of a pattern use the predominant colour in the pattern).
  5. Make sure the logo layer is selected and use fuzzy select (or your software’s equivalent) to select the transparent parts of your image. All of the transparent pixels should be included in the unselected area, see the example below, all the grey pixels are outside of the selection (when the area we want blank is selected).
  6. fuzzy select

  7. Now make sure the background colour layer is selected and delete the parts of the background colour within the mask that you just made with the select tool.

final results - tranparent GIF

The result is not particularly pretty when viewed in its transparent glory, but it will look much nicer when placed over it’s background colour or pattern!
The GIF itself

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on Pocket (Opens in new window) Pocket

Like this:

Like Loading...

Related

Filed Under: Graphics, Tutorials Tagged With: free, Free Software

Reader Interactions

Comments

  1. Marco Ruelicke.net says

    11 September 2007 at 03:39

    interesting tutorial, but may I add that there is some kind of IE6 hack which allows you fix the png bug? I don’t remember the hack right now, would have to research it again. If you want to know the hack, let me know and I will go through my older pages where I used it 🙂

  2. kristarella says

    11 September 2007 at 22:38

    Yep! I used that hack on my previous template. I seem to remember it working and then not working. I was using linux and checking IE on Browsershots. So, perhaps Browsershots just wasn’t giving the javascript time to load before taking the picture.
    I think I prefer this method to using hacks. It seems more solid because sometimes you can’t predict what someone else’s browser is going to do.

  3. Marco Ruelicke.net says

    12 September 2007 at 08:46

    good to see your blog being up again. :up: I checked your site earlier but after the server move it was a bit broken :shrug:

    Depending on your skills you could enable/disable the script based on the browser used. Browsershots in general is a useful tool, but usually it can’t check javascript related hacks, at least that’s what I experienced…

    Anyway, I just felt like that I should mention the hack, you never know… 😉

  4. kristarella says

    12 September 2007 at 17:16

    Yeh – they thought the move was going to take 4-8 hours, which I thought was fairly impressive. In the end it took closer to 24 hours with a few glitches after starting back up. Still, I respect the way they did things, it was a bold move to take everything down all at once and I think this past day of downage and glitches is better than a week or more of unreliability. Apparently the problems are all fixed now 😛

    Thanks for your comments! Suggestions never go astray 🙂

A triptych of baubles. These are very satisfying t A triptych of baubles. These are very satisfying to paint ❤️💚💙

#watercolor #watercolour #christmas
I have really enjoyed this Christmassy painting! S I have really enjoyed this Christmassy painting! So glad my friend asked me to make some cards for our church helpers, because it set me on a roll!
#watercolor #watercolour #christmas #christmascards #watercolorcards
Had a great Saturday at the GKR Karate State Title Had a great Saturday at the GKR Karate State Titles! I was a sub for @jamesxuereb.me in the Blue Flame Dragons thanks to his sprained ankle; we won first round and came fourth overall!
I did a bunch of judging and officiating, which was really good.
I didn’t place in my individual events, but had a very fun final round of kumite (sparring).

#gkrkarate #karate
More stamping tonight. Even better than last night More stamping tonight. Even better than last night’s!
Did some stamping this evening. Love it! I wish I’d done some pages in other ink colours before I dismantled the stamps 😂
Had an appointment in the city, so I got to visit Had an appointment in the city, so I got to visit the @legocertifiedstores_anz Wicked display!
#wicked #lego #afol #sydney
A little book I made from Bunnings paint sample ca A little book I made from Bunnings paint sample cards. It’s going to be for mini paintings and collages. Sometimes it’s nice to start with a colour rather than a blank white page!
A little while ago I did some swatching of Daniel A little while ago I did some swatching of Daniel Smith and Schminke Horodam watercolours. So soothing! I love some of the granulating colours!
#watercolours
Follow on Instagram

Footer

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Top Posts & Pages

  • Sistaco Nail Powder Review
    Sistaco Nail Powder Review
  • Boobs & Dinks - early cancer detection
    Boobs & Dinks - early cancer detection
  • Home
    Home
  • Edit EPS files in Inkscape on Mac
    Edit EPS files in Inkscape on Mac
  • Exifography
    Exifography

Follow Me On…

  • Instagram
  • X
  • GitHub
  • LinkedIn
  • YouTube

Categories

Copyright © 2025 · Kristen Symonds · kristarella.com

%d