您好,欢迎访问一九零五行业门户网

在线生成favicon.ico或ico图标源码

在线|favicon
php在线生成ico文件源代码.
favicon图标介绍favicon.ico一般用于作为缩略的网站标志,它显示位于浏览器的地址栏或者在标签上,用于显示网站的logo,如图红圈的位置, 目前主要的浏览器都支持favicon.ico图标.
以下是index.php源代码
210000){ 
            echo 你上传的文件体积超过了限制 最大不能超过200k; 
            exit(); 
        } 
        $fileext = array(image/pjpeg,image/gif,image/x-png); 
        if(!in_array($_files[’upimage’][’type’],$fileext)){ 
            echo 你上传的文件格式不正确 仅支持 jpg,gif,png; 
            exit(); 
        } 
        if($im = @imagecreatefrompng($_files[’upimage’][’tmp_name’]) or $im = @imagecreatefromgif($_files[’upimage’][’tmp_name’]) or $im = @imagecreatefromjpeg($_files[’upimage’][’tmp_name’])){ 
            $imginfo = @getimagesize($_files[’upimage’][’tmp_name’]); 
            if(!is_array($imginfo)){ 
                echo 图形格式错误!; 
            } 
            switch($_post[’size’]){ 
                case 1; 
                    $resize_im = @imagecreatetruecolor(16,16); 
                    $size = 16; 
                    break; 
                case 2; 
                    $resize_im = @imagecreatetruecolor(32,32); 
                    $size = 32; 
                    break; 
                case 3; 
                    $resize_im = @imagecreatetruecolor(48,48); 
                    $size = 48; 
                    break; 
                default; 
                    $resize_im = @imagecreatetruecolor(32,32); 
                    $size = 32; 
                    break; 
            } 
            imagecopyresampled($resize_im,$im,0,0,0,0,$size,$size,$imginfo[0],$imginfo[1]); 
            include phpthumb.ico.php; 
            $icon = new phpthumb_ico(); 
            $gd_image_array = array($resize_im); 
            $icon_data = $icon->gd2icostring($gd_image_array); 
            $filename = temp/.date(ymdhis).rand(1,1000)..ico; 
            if(file_put_contents($filename, $icon_data)){ 
                $output = 生成成功!请点右键->另存为 保存到本地
点击下载; 
            } 
        }else{ 
            echo 生成错误请重试!; 
        } 
    }     

?>
ico图标在线转换
ico图标在线转换
请上传你要转换的图片
支持格式 png,jpg,gif
目标尺寸: 
        16*16 
        32*32 
        48*48
powered by 非常爱漫
以下是phpthumb.ico.php源代码:
 $gd_image) {
            $imagewidths[$key]  = imagesx($gd_image);
            $imageheights[$key] = imagesy($gd_image);
            $bpp[$key]          = imageistruecolor($gd_image) ? 32 : 24;
            $totalcolors[$key]  = imagecolorstotal($gd_image);
            $icxor[$key] = ’’;
            for ($y = $imageheights[$key] - 1; $y >= 0; $y--) {
                for ($x = 0; $x                     $argb = $this->getpixelcolor($gd_image, $x, $y);
                    $a = round(255 * ((127 - $argb[’alpha’]) / 127));
                    $r = $argb[’red’];
                    $g = $argb[’green’];
                    $b = $argb[’blue’];
                    if ($bpp[$key] == 32) {
                        $icxor[$key] .= chr($b).chr($g).chr($r).chr($a);
                    } elseif ($bpp[$key] == 24) {
                        $icxor[$key] .= chr($b).chr($g).chr($r);
                    }
                    if ($a                         @$icandmask[$key][$y] .= ’1’;
                    } else {
                        @$icandmask[$key][$y] .= ’0’;
                    }
                }
                // mask bits are 32-bit aligned per scanline
                while (strlen($icandmask[$key][$y]) % 32) {
                    $icandmask[$key][$y] .= ’0’;
                }
            }
            $icand[$key] = ’’;
            foreach ($icandmask[$key] as $y => $scanlinemaskbits) {
                for ($i = 0; $i                     $icand[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, ’0’, str_pad_left)));
                }
            }
        }
        foreach ($gd_image_array as $key => $gd_image) {
            $bisizeimage = $imagewidths[$key] * $imageheights[$key] * ($bpp[$key] / 8);
            // bitmapinfoheader - 40 bytes
            $bitmapinfoheader[$key]  = ’’;
            $bitmapinfoheader[$key] .= \x28\x00\x00\x00;                              // dword  bisize;
            $bitmapinfoheader[$key] .= $this->littleendian2string($imagewidths[$key], 4);      // long   biwidth;
            // the biheight member specifies the combined
            // height of the xor and and masks.
            $bitmapinfoheader[$key] .= $this->littleendian2string($imageheights[$key] * 2, 4); // long   biheight;
            $bitmapinfoheader[$key] .= \x01\x00;                                      // word   biplanes;
               $bitmapinfoheader[$key] .= chr($bpp[$key]).\x00;                          // wbitcount;
            $bitmapinfoheader[$key] .= \x00\x00\x00\x00;                              // dword  bicompression;
            $bitmapinfoheader[$key] .= $this->littleendian2string($bisizeimage, 4);            // dword  bisizeimage;
            $bitmapinfoheader[$key] .= \x00\x00\x00\x00;                              // long   bixpelspermeter;
            $bitmapinfoheader[$key] .= \x00\x00\x00\x00;                              // long   biypelspermeter;
            $bitmapinfoheader[$key] .= \x00\x00\x00\x00;                              // dword  biclrused;
            $bitmapinfoheader[$key] .= \x00\x00\x00\x00;                              // dword  biclrimportant;
        }
        $icondata  = \x00\x00;                                      // idreserved;   // reserved (must be 0)
        $icondata .= \x01\x00;                                      // idtype;       // resource type (1 for icons)
        $icondata .= $this->littleendian2string(count($gd_image_array), 2);  // idcount;      // how many images?
        $dwimageoffset = 6 + (count($gd_image_array) * 16);
        foreach ($gd_image_array as $key => $gd_image) {
            // icondirentry   identries[1]; // an entry for each image (idcount of ’em)
            $icondata .= chr($imagewidths[$key]);                     // bwidth;          // width, in pixels, of the image
            $icondata .= chr($imageheights[$key]);                    // bheight;         // height, in pixels, of the image
            $icondata .= chr($totalcolors[$key]);                     // bcolorcount;     // number of colors in image (0 if >=8bpp)
            $icondata .= \x00;                                      // breserved;       // reserved ( must be 0)
            $icondata .= \x01\x00;                                  // wplanes;         // color planes
            $icondata .= chr($bpp[$key]).\x00;                      // wbitcount;       // bits per pixel
            $dwbytesinres = 40 + strlen($icxor[$key]) + strlen($icand[$key]);
            $icondata .= $this->littleendian2string($dwbytesinres, 4);       // dwbytesinres;    // how many bytes in this resource?
            $icondata .= $this->littleendian2string($dwimageoffset, 4);      // dwimageoffset;   // where in the file is this image?
            $dwimageoffset += strlen($bitmapinfoheader[$key]);
            $dwimageoffset += strlen($icxor[$key]);
            $dwimageoffset += strlen($icand[$key]);
        }
        foreach ($gd_image_array as $key => $gd_image) {
            $icondata .= $bitmapinfoheader[$key];
            $icondata .= $icxor[$key];
            $icondata .= $icand[$key];
        }
        return $icondata;
    }
    function littleendian2string($number, $minbytes=1) {
        $intstring = ’’;
        while ($number > 0) {
            $intstring = $intstring.chr($number & 255);
            $number >>= 8;
        }
        return str_pad($intstring, $minbytes, \x00, str_pad_right);
    }
    function getpixelcolor(&$img, $x, $y) {
        if (!is_resource($img)) {
            return false;
        }
        return @imagecolorsforindex($img, @imagecolorat($img, $x, $y));
    }
}
?>
其它类似信息

推荐信息