[advanced search]
Results from the most recent live auction are here.
17 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Webmaster Tutorials
User Name
Password

Old 09-19-2007, 07:28 PM   · #1
RaptorRex
NamePros Member
 
RaptorRex's Avatar
 
Trader Rating: (0)
Join Date: Dec 2004
Posts: 90
NP$: 172.00 (Donate)
RaptorRex is an unknown quantity at this point
Making transparent PNG files that work in IE

There is a general belief that IE6 does not support transparent PNG files at all. This isn't actually true. IE6 supports PNG transparency in indexed mode (a palette) but not in 24-bit color mode. I'll describe what this means and how to create the all elusive transparent PNG files that work with Internet Explorer.

Below is a transparent PNG that shows just fine in IE:


PNG files can store color information in two ways: on a palette and in RGBA mode. A palette reserves a fixed number of colour slots where each slot can store one color. A full palette usually has 256 available slots, therefore 256 colours available for the image. Any colour can go into a colour slot. The 256 colours could all be shades of red, or be a rainbow spectrum of all colours. Since colours in the image can only be indexed as a colour slot (0-255), each pixel in the image can be represented by a single byte.

RGBA mode provides 4 bytes of colour information per pixel. Each of Red, Green and Blue is given a value of 0-255. One other "channel" is called the Alpha-channel. The alpha channel defines the transparency of the pixel in a range of 0-255. This results in an image being able to display over 16 million colours with a range of transparency for each pixel.

To properly support transparency the alpha-channel needs to be supported. Internet Explorer does not correctly handle the alpha-channel of a PNG file. However IE does support a different kind of transparency which makes it just a flexible as the another kind of transparency-supporting image called a GIF.

A color slot in a paletted PNG can be designated to not be a colour at all, but to be transparent. This means that a pixel defined by this slot simply won't have any colour drawn for it. This is the same method used by GIF and is supported by IE.

To make your PNG transparency work in IE you must convert the image from 24-bit colour to an indexed palette. Then you must assign a palette position to be transparent, or depending on your imaging tool, assign a colour or image area to be converted to transparency. I will describe how this is done using GIMP. GIMP is a free photo editor from gimp.org and although a little difficult to learn at first is very powerful. The principles described here should apply to any good graphics program.

Open an image that requires transparency in GIMP.

In the GIMP menu select Layer->Transparency->Semi-Flatten. What flattening does is to merge items together. In this case you are merging all semi-transparent pixels into solid colours that don't have transparency and fully transparent pixels are kept that fully transparent. After doing this you have either fully transparent pixels or colour pixels. The alpha channel will be gone or useless.

Next you need to change the colour format from 24-bit colour to an indexed palette. In the GIMP menu select Image->Mode->Indexed. This will open a box to assign settings to your palette. It is best to "Generate Optimum Palette" with 256 colours for photos. If you know you have fewer colours you can choose fewer colours (as is the case for plain logos that have no color gradients). Push "Ok" and save your transparent PNG file.

And that is it. In the case of GIMP it will have assigned one palette position to represent a 100% transparent pixel. This is recognized by IE and the transparency will work correctly therein.

Although this was done using GIMP, the principles are the same for any image program. Simply flatten your alpha-channel and convert your image to 256 colours and the image program should do the rest.


Please register or log-in into NamePros to hide ads
__________________
http://UpWithABang.com/clips - free mail forms, guestbooks, and more
http://UpWithABang.com/developer-resources.html - for web tutorials, how-tos, and more
Free game download: http://UpWithABang.com/52Pickup - it's fun. Trust me. I'm a developer.
RaptorRex is offline   Reply With Quote
Old 09-19-2007, 07:38 PM   · #2
-Nick-
I'll do it
 
-Nick-'s Avatar
 
Name: Keral. Patel.
Location: India
Trader Rating: (98)
Join Date: Dec 2005
Posts: 5,414
NP$: 9192.05 (Donate)
-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute-Nick- has a reputation beyond repute
Member of the Month
September 2007 Adoption
A very good one here.

Thanking you for your contribution.

-Nick.
-Nick- is offline   Reply With Quote
Old 09-25-2007, 10:54 PM   · #3
DylanButler
NamePros Regular
 
DylanButler's Avatar
 
Name: Dylan Butler
Location: San Diego, CA
Trader Rating: (38)
Join Date: Jan 2006
Posts: 693
NP$: 0.00 (Donate)
DylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to behold
Interesting - can you set an area to be transparent as well? As opposed to choosing a color and risking transparent spots all over your image.

Indexed color mode does not support semi-transparency, right? So you'd still have to choose a matte color if you wanted to avoid jaggedness?

Why not just use a GIF?

Great find nonetheless.
__________________
-Dylan Butler

Coming soon: examp
DylanButler is offline   Reply With Quote
Old 09-26-2007, 07:50 AM   · #4
Steve
Bargain Hunter
 
Steve's Avatar
 
Name: Steve
Location: Pennsylvania, USA
Trader Rating: (61)
Join Date: Jan 2006
Posts: 3,530
NP$: 2642.76 (Donate)
Steve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond reputeSteve has a reputation beyond repute
Ethan Allen Fund Cancer Survivorship Special Olympics Protect Our Planet Protect Our Planet
Originally Posted by DylanButler
Interesting - can you set an area to be transparent as well? As opposed to choosing a color and risking transparent spots all over your image.

Indexed color mode does not support semi-transparency, right? So you'd still have to choose a matte color if you wanted to avoid jaggedness?

Why not just use a GIF?

Great find nonetheless.


In this case, I think it would make more sense to use a GIF -- you wouldn't have any semi-transparent areas this way, which is why PNGs are used most. If you need more quality (257+ colors) with transparency for whatever reason, use a PNG.

Still a nice find.

Semi-transparent PNGs work with a piece of Javascript, I believe.
__________________
Get your brand recognized with a racing league sponsorship
Happy 3 millionth post, NamePros!

Last edited by Etab : 09-26-2007 at 10:31 AM.
Steve is offline  
  Reply With Quote
Old 09-26-2007, 10:17 AM   · #5
AzN
Is away for a while.
 
AzN's Avatar
 
Location: San Francisco, CA
Trader Rating: (105)
Join Date: May 2006
Posts: 2,454
NP$: 277.00 (Donate)
AzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond repute
Find Marrow Donors! Ethan Allen Fund Ethan Allen Fund Ethan Allen Fund Save a Life Save a Life Save a Life Save a Life Save a Life Save a Life VA Tech Memorial VA Tech Memorial VA Tech Memorial VA Tech Memorial Save a Life Save a Life Save a Life
Originally Posted by DylanButler
Interesting - can you set an area to be transparent as well? As opposed to choosing a color and risking transparent spots all over your image.

Indexed color mode does not support semi-transparency, right? So you'd still have to choose a matte color if you wanted to avoid jaggedness?

Why not just use a GIF?

Great find nonetheless.




I never found a way to use GIF without distortion.
__________________
My Portfolio: ServiceInteract Creatives
Shrink your URLs with URLShrinker.net!
For all hosting info, HostReports.com
I recommend TheHiveDesigns and Fucian Tech for web design services.
AzN is offline   Reply With Quote
Old 09-26-2007, 03:53 PM   · #6
DylanButler
NamePros Regular
 
DylanButler's Avatar
 
Name: Dylan Butler
Location: San Diego, CA
Trader Rating: (38)
Join Date: Jan 2006
Posts: 693
NP$: 0.00 (Donate)
DylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to beholdDylanButler is a splendid one to behold
Originally Posted by AzN
I never found a way to use GIF without distortion.


If you are using photoshop -> Save for Web.. You can choose a 'Matte Color' (default is usually white). Set this color to whatever background color you expect the image to sit on.

Originally Posted by Etab
Semi-transparent PNGs work with a piece of Javascript, I believe.

Yes there is a pngfix.js but it does not always work on first load in IE6. Also it can slow the page because it works off of IE's alpha filter (basically it goes through your document and adds a filter to every image ending in .png).
__________________
-Dylan Butler

Coming soon: examp
DylanButler is offline   Reply With Quote
Old 09-27-2007, 10:00 PM   · #7
RaptorRex
NamePros Member
 
RaptorRex's Avatar
 
Trader Rating: (0)
Join Date: Dec 2004
Posts: 90
NP$: 172.00 (Donate)
RaptorRex is an unknown quantity at this point
Originally Posted by DylanButler
Interesting - can you set an area to be transparent as well? As opposed to choosing a color and risking transparent spots all over your image.

Indexed color mode does not support semi-transparency, right? So you'd still have to choose a matte color if you wanted to avoid jaggedness?

Why not just use a GIF?

Great find nonetheless.



You choose colors not areas. You cannot have semi-transparency with a (indexed) palette. Yes, a matte color is appropriate for the anti-aliasing just like in GIF.

PNG compression is better than GIF compression. Packets are between 500-800 bytes, so you can reduce your fetches accordingly.

You will have the same problems with PNG indexed transparency as you have with GIF but PNG ends up smaller. PNG also supports some extra fields like resolution and background colour. Make sure you null these fields if you aren't using them so as to save more space.
__________________
http://UpWithABang.com/clips - free mail forms, guestbooks, and more
http://UpWithABang.com/developer-resources.html - for web tutorials, how-tos, and more
Free game download: http://UpWithABang.com/52Pickup - it's fun. Trust me. I'm a developer.
RaptorRex is offline   Reply With Quote
Old 09-29-2007, 12:09 AM   · #8
Lord
Senior Member
 
Trader Rating: (6)
Join Date: Jun 2003
Posts: 1,354
NP$: 12.85 (Donate)
Lord is a jewel in the roughLord is a jewel in the roughLord is a jewel in the rough
thanks a lot =) I was actually looking for a long time on how to get/make transparent pngs(or other images)

ended up going through numerous transparent image generators until I could find one (of course, they can only generate text)

thanks for the guide
Lord is offline   Reply With Quote
Old 10-04-2007, 06:59 AM   · #9
rajdx
New Member
 
Trader Rating: (0)
Join Date: Oct 2007
Posts: 2
NP$: 0.00 (Donate)
rajdx is an unknown quantity at this point
Wow...thanks a lot dude....I'm looking for this for a long time since IE 6 doesnt support transparent PNG....Thank god they made IE 7 support transparent PNG
rajdx is offline   Reply With Quote
Old 10-05-2007, 03:43 AM   · #10
bbalegere
Senior Member
 
Name: Bharat Balegere
Location: Bangalore
Trader Rating: (15)
Join Date: Jul 2005
Posts: 1,178
NP$: 9.25 (Donate)
bbalegere is just really nicebbalegere is just really nicebbalegere is just really nicebbalegere is just really nice
Wow!
This is a good tutorial.
It will definitely help me.
bbalegere is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Find out how! Proof is in the Parking Arcade Script
Advertise your business at NamePros
All times are GMT -7. The time now is 10:21 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0