Convert ICO to PNG or GIF?

Discussion in 'PHP' started by pcdivenii, Sep 14, 2007.

  1. #1
    I'm looking for a PHP script (or anything server-side) that can convert ICO images (favicons) to either PNG or GIF.


    I tried this PHP class, but it tends to generate a lot of noise in PNGs for some favicons:

    controlstyle.com/articles/programming/text/php-favicon/


    Anyone know of a script that converts ICO to PNG or GIF?


    Thanks for your help!
     
    pcdivenii, Sep 14, 2007 IP
  2. Rogem

    Rogem Peon

    Messages:
    171
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I know PHP can turn a PNG, JPG, BMP and GIF image into almost any other image (via headers).

    What you could try doing is getting the code from the ICO and sending it back as a PNG.

    
    <?php
    header("Content-Type: image/png");
    echo file_get_contents("file.ico");
    ?>
    
    PHP:
    It most likely will not work, but you could give it a go :)

    If that files, look for a shell script that does this.
     
    Rogem, Sep 15, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    You're fooling the browser this way. PHP doesn't do any changes on the image and doesn't convert anything. And if it works, it may not work on all browsers.
     
    nico_swd, Sep 15, 2007 IP
  4. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    For ICO stuff, I always use the net NetPBM library via exec() calls. Messy (and can load the CPU), but reliable.

    Also, there's a native PHP library for ICO manipulation, but I don't remember what it's called. You can search for it at sourceforge.net
     
    sea otter, Sep 15, 2007 IP
  5. yangyang

    yangyang Banned

    Messages:
    757
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry for digging up this thread but I thought this one may help visitors who have searched through Google to here for an answer.

    If you are just an end user you may use this online image converter that converts .ICO to .PNG and vice versa.

    Actually it does much more than an ordinary one-way image converter. It's almost an all-image converter that converts between all common image formats.
     
    yangyang, Oct 7, 2008 IP