Is .png ok?

Discussion in 'HTML & Website Design' started by fryman, Oct 7, 2005.

  1. #1
    I am using a template that is full of .png images. Are these OK? Can they be seen with any browser, or should I change them to gifs?
     
    fryman, Oct 7, 2005 IP
  2. Epica

    Epica Well-Known Member

    Messages:
    1,007
    Likes Received:
    95
    Best Answers:
    0
    Trophy Points:
    170
    #2
    I might be mistaken, but I don't think IE recognizes the PNG file type yet. Firefox does though...if my memory serves me correctly
     
    Epica, Oct 7, 2005 IP
  3. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #3
    that's weird, I use IE and can see them fine... if anyone can confirm this I'd appreciate it, it has loads of images and changing their extension would be a real pain
     
    fryman, Oct 7, 2005 IP
  4. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #4
    PNG has been fully accepted as a successor to GIF and JPEG : No weird patents, fully open source and implemented as such in most modern browsers.

    While I'm typing this I just think about google images.. let me check
    ok. google images also understands png files: http://images.google.com/images?q=png&hl=en

    Netscape 0.9beta users will complain tough ;)
     
    frankm, Oct 7, 2005 IP
  5. Epica

    Epica Well-Known Member

    Messages:
    1,007
    Likes Received:
    95
    Best Answers:
    0
    Trophy Points:
    170
    #5
    I should constrain my comments to those subject where I'm not completely clueless - sorry - heh ;)
     
    Epica, Oct 7, 2005 IP
  6. LGRComp

    LGRComp Well-Known Member

    Messages:
    516
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    195
    #6
    IE 6 handles .pngs fine except IE 6 will not properly display a .png with an alpha channel, where as Firefox will. That is how some sites get that cool transparent look to them in Firefox, while they show up as plain coloured backgrounds in IE.
     
    LGRComp, Oct 7, 2005 IP
  7. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #7
    @LGRComp:
    you can work around this by putting the PNG (or any other image) in a DIV that has a "FILTER: ALPHA(opacity=x)" style.
     
    frankm, Oct 7, 2005 IP
  8. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #8
    Cool... I have just been glued to my computer for the last 10 hours finishing a site, and having to change my images would of taken a few hours...
     
    fryman, Oct 8, 2005 IP
  9. Neoto

    Neoto Active Member

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #9
    IE can handle some transparency but not all. I've noted that only 8-bit PNGs work sufficiently. More info here.
     
    Neoto, Oct 8, 2005 IP
  10. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #10
    if u feel uncomfortable u can always take those in fireworks or photoshop and export as gif or jpeg.
     
    king_cobra, Oct 8, 2005 IP
  11. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #11
    i use .png all the time, especially for logos, they are small in size and still kepp there quality and ive never had problems with them.
     
    just-4-teens, Oct 8, 2005 IP
  12. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #12
    You can get IE to handle an alpha channeled png with a css behavior - http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html

    It really opens up your options, but puts a little bit of extra weight on your pages. Mozilla browsers support alpha channels without any changes.

    IE6 I believe started supporting png's, but I don't believe older IE versions support them.
     
    nevetS, Oct 8, 2005 IP
  13. cagintranet

    cagintranet Well-Known Member

    Messages:
    328
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #13
    ive had the exact opposite reaction with .png's. while they are of the best quality, it does show up in the size of the image. They tend to be easily double/triple the size of the gif/jpeg alt versionof the same image. I have found that i keep my .pngs only around if i want to end up changing something on an image. I then export it to a GIF if it needs to be transparent and a JPEG if otherwise. My preference leans to the JPEG format - it seems to keep its quality better with a small image size.

    my web pages tend to be on the large side, so anywhere i can save some size i need to.
     
    cagintranet, Oct 8, 2005 IP
  14. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #14
    There are compression utilities out there for png's, but none of the major software - photoshop, fireworks, corel, etc. seem to have that option built in.

    There are a series of utilities listed here: http://www.libpng.org/pub/png/pngapcv.html
     
    nevetS, Oct 8, 2005 IP
  15. UndiesHosting

    UndiesHosting Active Member

    Messages:
    219
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    78
    #15
    In response to the original question, as others have said, PNGs can be viewed by any browser. The only limitation is in PNGs that have transparent parts in them, will not be displayed properly in Internet Explorer.

    However, there is a fix for this via CSS and I have a nice little piece of javascript that checks for the browser type and does the necessary fix on the graphics when someone is using a version of IE that would not display the graphics properly.

    put this in the <head> portion of your html files:

    
    <!--[if gte IE 5.5000]>
    <script type="text/javascript" src="pngfix.js"></script>
    <![endif]-->
    
    Code (markup):

    the javascript is below:

    // Correctly handle PNG transparency in Win IE 5.5 or higher.
    // http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
    
    function correctPNG() 
       {
       for(var i=0; i<document.images.length; i++)
          {
    	  var img = document.images[i]
    	  var imgName = img.src.toUpperCase()
    	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
    	     {
    		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
    		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
    		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
    		 var imgStyle = "display:inline-block;" + img.style.cssText 
    		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
    		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
    		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
    		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
    		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
    	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
    		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
    		 img.outerHTML = strNewHTML
    		 i = i-1
    	     }
          }
       }
    window.attachEvent("onload", correctPNG);
    Code (markup):
    As for file size, generalizing about PNG, GIF and JPG will often just create arguments. It is most important to use the proper format for the job. A logo that may only have 2 or 4 colors, would be significantly smaller as a GIF or 8-bit PNG, and larger as a JPG or 24-bit PNG because there is more overhead in the file type than necessary to save the data in the file.

    Consequently, in a photograph using JPGs full range of 16.7 million possible colors will result in a better quality image than GIF (limited to only 256 colors) and may even be a smaller file size as well.

    As preference, 24-bit PNGs seem to be a great replacement for any place I would normally use a GIF file.
     
    UndiesHosting, Oct 8, 2005 IP
  16. [GeNe]

    [GeNe] Peon

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    PNG is supportable in every browser. If you've got transparency, PNG works well in Firefox but in IE it goes screwy and the background is not transparent. However transparency in GIF works good on both browsers so if you have transparency in the template, consider changing it to gifs.
     
    [GeNe], Oct 8, 2005 IP
  17. tbh

    tbh Peon

    Messages:
    1,130
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #17
    This thread is super old, but just as a side note, IE 6 displays PNG's correctly except for some color errors (think of the difference between CMYK and RGB).

    A site full of PNG's is fine. But when you mix PNGs with GIFs or JPGs you risk having the colors look wierd and not match.
     
    tbh, Aug 16, 2007 IP