Step 2: Use phpthumb to convert a png into ico
I have programmed a demo to show how to use phpthumb to convert a png into a ico file. Sample code below:
<?php include "phpthumb.ico.php"; include "phpthumb.functions.php"; // step 1: get png image $png_data=imagecreatefrompng ("stepor.png"); // step 2: convert png to ico $gd_image_array = array($png_data); $icon=new phpthumb_ico; $ico_data = $icon->GD2ICOstring($gd_image_array); // step 3: save ico image $filename = "stepr.ico"; file_put_contents($filename,$ico_data); ?>
In this sample code, i convert a file called stepor.png into stepr.ico. and the result is below:
Comparing stepor.png and ster.ico you can find, the quality and size of image are the same, the only difference of them is format, one is pnge and the other is ico.
Google+Pages: 1 2