検索
ホームページバックエンド開発PHPチュートリアルico ファイルを生成するための PHP のコード online_PHP チュートリアル
ico ファイルを生成するための PHP のコード online_PHP チュートリアルJul 21, 2016 pm 03:55 PM
geicoindex.phpissetoutputphpコードオンラインコピー書類生成する

Index.php

コードをコピーします コードは次のとおりです:

$output = "";
if(isset($_GET['action'])&&$_GET['action'] == 'make'){
if(isset($_FILES[' upimage']['tmp_name']) && $_FILES['upimage']['tmp_name'] && is_uploaded_file($_FILES['upimage']['tmp_name'])){
if($_FILES['upimage'] ['type']> 210000){image/gif "、" image/x-png ");
echo" アップロードしたファイル形式、png";
exit() }
if($im = @imagecreatefrompng($_FILES['upimage']['tmp_name']) または $im = @imagecreatefromgif($_FILES) ['upimage']['tmp_name ']) または $im = @imagecreatefromjpeg($_FILES['upimage']['tmp_name'])){
$imginfo = @getimagesize($_FILES['upimage']['tmp_name ']);
Is_array ($ Imginfo) {
Echo "グラフィック形式エラー!";
}
switch($_POST['size']){
case 1;
$resize_im = @imagecreatetruecolor(16,16) ;
$size = 16;
$resize_im = @ imagecreatetruecolor(32,32);
$size = 32;
ケース 3; $resize_im = @imagecreatetruecolor(48,48);
$size = 48;
デフォルト; $resize_im = @imagecreatetruecolor (32,32);
$size = 32;
break
imagecopyresampled($resize_im,$im,0,0) ,0,0,$size,$size,$imginfo[0],$imginfo[1] ]);
"phpthumb.ico.php";
$icon = new phpthumb_ico(); $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 " 生成错误请重试!

body{背景色: #fff;color:#000000;font-family:arial;margin:30px;font-size:12px;}
table{border:0}
td{line-height:16px;}
label{cursor:hand;}

ICO アイコンオンライン変換

method="post" enctype= 'multipart/form-data'>
gif ;16*16
> ;
;?PHP
if($output){
echo "< ;tr>"; :11px;">Powered by ベリーラブコミックス

///////////////////////////////////////// ///////////////////
/// phpThumb() by James Heinrich    //
// http://phpthumb.sourceforge.net ///
////////////////////////////// で入手可能////////////////////////////////
/// //
// phpthumb.ico.php - .ICO 出力フォーマット機能 //
//////////////////////////////////////////////////////////////////// /// ///////////////////////


class phpthumb_ico {

function phpthumb_ico() {
return true;
}


function GD2ICOstring(&$ gd_image_array) {
foreach ($gd_image_array as $key => $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' ;
}
}
//マスクビットは走査線ごとに32ビットにアライメントされます
その間 (strlen($icANDm ask[$key][$y]) % 32) {
$icANDmask[$key][$y] .= '0';
}
}
$icAND[$key] = '';
foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
for ($i = 0; $i $icAND[$key] .= chr(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);

// ビットマップヘッダー- 40 バイト
$BitmapInfoHeader[$key] = '';
$BitmapInfoHeader[$key] .= "x28x00x00x00";                              // DWORD biSize;
$BitmapInfoHeader[$key] .= $this->LittleEndian2String($ImageWidths[$key], 4);      // LONG biWidth;
// biHeight メンバーは XOR マスクと AND マスクの組み合わせ
// 高さを指定します。
$BitmapInfoHeader[$key] .= $this->LittleE ndian2String($ImageHeights[$key] * 2, 4); // LONG biHeight;
$BitmapInfoHeader[$key] .= "x01x00";                                      // WORD biPlanes;
$BitmapInfoHeader[$key] .= chr($bpp[$key])."x00";                          // wBitCount;
$BitmapInfoHeader[$key] .= "x00x00x00x00";                              // DWORD biCompression;
$BitmapInfoHeader[$key] .= $this->LittleEndian2String($biSizeImage, 4);            // DWORD biSizeImage;
$BitmapInfoHeader[$key] .= "x00x00x00x00";                              // LONG biXPelsPerMeter;
$BitmapInfoHeader[$key] .= "x00x00x00x00";                              // LONG biYPelsPerMeter;
$BitmapInfoHeader[$key] .= "x00x00x00x00";                              // DWORD biClrused;
$BitmapInfoHeader[$key] .= "x00x00x00x00";                              // DWORD biClr重要;
}


        $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 >gt; 0) {
$intstring = $intstring.chr($number & 255);
$number >>= 8;
return str_pad($intstring, $分バイト、「x00」、 STR_PAD_RIGHT);
}

関数GetPixelColor(&$img, $x, $y) {
if (!is_resource($img)) {
return false;
}
return @ImageColorsForIndex($img, @ImageColorAt($ img, $x, $y));
}

}

?>

http://www.bkjia.com/PHPjc/318401.htmlwww.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/318401.html技術記事 Index.php 复制代码代码如下: ?PHP $output=""; if(isset($_GET['action'])$_GET['action']=='make'){ if(isset($_FILES['upimage']['tmp_name'])$_FILES['upimage'] ['tmp_name']is_upl...
".$ 出力。"
声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace("&nbsp;","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

SublimeText3 Linux 新バージョン

SublimeText3 Linux 新バージョン

SublimeText3 Linux 最新バージョン

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

WebStorm Mac版

WebStorm Mac版

便利なJavaScript開発ツール

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター