php画像アップロードクラスはサムネイルの生成と透かしの追加を同時に行うことができます この画像アップロード コードは、アップロードされた画像に透かしを追加したり、小さな画像を生成したり、テキストの透かしを生成したりできます。
PHP チュートリアルの画像アップロード クラスでは、サムネイルの生成と透かしの追加を同時に行うことができます
この画像アップロード コードは、アップロードされた画像に透かしを追加したり、小さな画像を生成したり、テキストの透かしを生成したりできます。
クラスアップ画像 {
var $annexfolder = "upload";//添付ファイルの保存ポイント、デフォルトは: annex
var $smallfolder = "small";//サムネイルの保存パス、注意: $annexfolder の下のサブディレクトリに配置する必要があり、デフォルトは smallimg
var $markfolder = "mark";//ウォーターマーク画像の保管場所
var $upfiletype = "jpg gif png";//アップロードの種類、デフォルトは: jpg gif png rar zip
var $upfilemax = 1024; //アップロード サイズ制限、単位は「kb」、デフォルトは 1024kb
var $fonttype;//フォント
var $maxwidth = 500 //画像の最大幅
; var $maxheight = 600 //画像の最大高さ
; 関数 upimages($annexfolder,$smallfolder,$includefolder) {
$this->smallfolder = $smallfolder;
$this->fonttype = $includefolder."/04b_08__.ttf";
}
関数アップロード($inputname) {
$imagename = time();// 現在の時間を画像名として設定します
If(@empty($_files[$inputname]["name"])) die("画像情報がアップロードされていません。ご確認ください");
$name =explode(".",$_files[$inputname]["name"]);//アップロードする前にファイルを「.」で区切ってファイルタイプを取得します
$ Imgcount = Count ($ Name) // インターセプト数を取得します
; $imgtype = $name[$imgcount-1];// ファイルの種類を取得します
If(strpos($this->upfiletype,$imgtype) === false) die(error("アップロード ファイル タイプは ".$this->upfiletype のみをサポートします。" は ".$imgtype" をサポートしません));
$ photo = $ imagename。 "。"。$ imgtype; //ファイル名データベースチュートリアルに書き込む $uploadfile = $this->annexfolder."/".$photo;//アップロードされたファイルの名前
$upfileok = move_uploaded_file($_files[$inputname]["tmp_name"],$uploadfile);
If($upfileok) {
$imgsize = $_files[$inputname]["size"];
$ksize =round($imgsize/1024);
If($ksize > ($this->upfilemax*1024)) {
die(error("アップロードされたファイルが ".$this->upfilemax."kb" を超えています));
} else {
die(エラー( "画像のアップロードに失敗した場合、アップロードされたファイルが$ upfilemax kbまたはアップロードタイムアウトを超えないことを確認してください");
}
$photo を返す;
}
関数 getinfo($photo) {
$photo = $this->別館フォルダー."/".$photo;
$imageinfo = getimagesize($photo);
$imginfo["width"] = $imageinfo[0];
$imginfo["高さ"] = $imageinfo[1];
$imginfo["type"] = $imageinfo[2];
$imginfo["名前"] = ベース名($photo);
$imginfo;
を返す }
関数 smallimg($photo,$width=128,$height=128) {
$imginfo = $this->getinfo($photo);
$photo = $this->annexfolder."/".$photo;//画像ソースを取得します
$newname = substr($imginfo["name"],0,strrpos($imginfo["name"], "."))."_thumb.jpg";//新しい画像名
If($imginfo["type"] == 1) {
$img = imagecreatefromgif($photo);
} elseif($imginfo["type"] == 2) {
$img = imagecreatefromjpeg($photo);
} elseif($imginfo["type"] == 3) {
$img = imagecreatefrompng($photo);
} else {
$img = "";
}
If(empty($img)) は false を返します;
$width = ($width > $imginfo["width"]) $imginfo["width"] : $width; $height = ($height > $imginfo["height"]) $imginfo["height"] : $height; $srcw = $imginfo["width"]; $srch = $imginfo["高さ"]; If ($srcw * $width > $srch * $height) {
$height =round($srch * $width / $srcw);
} else {
$width =round($srcw * $height / $srch);
}
if (function_exists("imagecreatetruecolor")) {
$newimg = imagecreatetruecolor($width, $height);
imagecopyresampled($newimg, $img, 0, 0, 0, 0, $width, $height, $imginfo["width"], $imginfo["height"]);
} その他 {
$newimg = imagecreate($width, $height);
imagecopyresize($newimg, $img, 0, 0, 0, 0, $width, $height, $imginfo["width"], $imginfo["height"]);
}
if ($this->tofile) {
if (file_exists($this->annexfolder."/".$this->smallfolder."/".$newname)) @unlink($this->annexfolder."/".$this->smallfolder) ."/".$新しい名前);
imagejpeg($newimg,$this->annexfolder."/".$this->smallfolder."/".$newname);
return $this->annexfolder."/".$this->smallfolder."/".$newname;
} その他 {
imagejpeg($newimg);
}
imagedestroy($newimg);
imagedestroy($img);
$newname を返します;
}
関数ウォーターマーク($photo,$text) {
$imginfo = $this->getinfo($photo);
$photo = $this->別館フォルダー."/".$photo;
$newname = substr($imginfo["name"], 0, strrpos($imginfo["name"], ".")) 。 "_mark.jpg";
スイッチ ($imginfo["type"]) {
ケース1:
$img = imagecreatefromgif($photo);
休憩;
ケース 2:
$img = imagecreatefromjpeg($photo);
休憩;
ケース 3:
$img = imagecreatefrompng($photo);
休憩;
デフォルト:
false を返します;
}
if (empty($img)) return false;
$width = ($this->maxwidth>$imginfo["width"]) ? $imginfo["width"] : $this->maxwidth;
$height = ($this->maxheight>$imginfo["height"]) ? $imginfo["高さ"] : $this->maxheight;
$srcw = $imginfo["幅"];
$srch = $imginfo["身長"];
if ($srcw * $width > $srch * $height) {
$height =round($srch * $width / $srcw);
} その他 {
$width =round($srcw * $height / $srch);
}
if (function_exists("imagecreatetruecolor")) {
$newimg = imagecreatetruecolor($width, $height);
imagecopyresampled($newimg, $img, 0, 0, 0, 0, $width, $height, $imginfo["width"], $imginfo["height"]);
} その他 {
$newimg = imagecreate($width, $height);
imagecopyresize($newimg, $img, 0, 0, 0, 0, $width, $height, $imginfo["width"], $imginfo["height"]);
}
$white = imagecolorallocate($newimg, 255, 255, 255);
$black = imagecolorallocate($newimg, 0, 0, 0);
$alpha = imagecolorallocatealpha($newimg, 230, 230, 230, 40);
imagefilledrectangle($newimg, 0, $height-26, $width, $height, $alpha);
imagefilledrectangle($newimg, 13, $height-20, 15, $height-7, $black);
imagettftext($newimg, 4.9, 0, 20, $height-14, $black, $this->fonttype, $text[0]);
imagettftext($newimg, 4.9, 0, 20, $height-6, $black, $this->fonttype, $text[1]);
if($this->tofile) {
if (file_exists($this->annexfolder."/".$this->markfolder."/".$newname)) @unlink($this->annexfolder."/".$this->markfolder) ."/".$新しい名前);
imagejpeg($newimg,$this->annexfolder."/".$this->markfolder."/".$newname);
return $this->annexfolder."/".$this->markfolder."/".$newname;
} その他 {
imagejpeg($newimg);
}
imagedestroy($newimg);
imagedestroy($img);
$newname を返します;
}
}

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

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

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

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

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

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

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

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


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

Dreamweaver Mac版
ビジュアル Web 開発ツール

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

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

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!
