views:

296

answers:

4

Hi,

I would like to create a PHP script that convert a png file to an ico file. Is it possible to do it just with PHP ? How ?

Thanks !!!

A: 

There is no easy way to do this directly though php built in libraries. To write an ico file, you will need to write individual bits and bytes by hand to suit the file format. The easiest way would be to use a third party library.

phpthumb is a good tool for this.

http://phpthumb.sourceforge.net/

Cahlroisse
+1  A: 

This seems to suggest Imagick can do this.

Otherwise, you could do the conversion on the server using an external tool and server the .ico file. Tools to achieve this have been analyzed in Stack Overflow before (well, doing the opposite transformation, but I bet most of that software can do what you need).

Roberto Aloi
+2  A: 

After some googling and light experimentation, it appears that an .ico file is basically a BMP with another file extension. I believe the ICO format supports more resolutions in one file, but a BMP seems to constitute a minimal ICO file. You should be able to generate BMP files easily with gd or ImageMagick.

deceze
gd does not save .ico files as I know
php html
@php Sorry, you missed the point. If my speculation about ICO files being extended BMP files is correct, it should work.
deceze
A: 

I would give floIcon a try: http://tech.flobi.com/test/floIcon/

Joe Scylla