日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 图像 处理,PHP 处理图像步骤解析

發布時間:2025/4/5 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 图像 处理,PHP 处理图像步骤解析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

PHP 處理圖像步驟解析

發布時間:2020-05-09 16:25:55

來源:億速云

閱讀:309

作者:Leah

今天小編就為大家帶來一篇PHP中處理圖像的文章。小編覺得挺不錯的,為此分享給大家做個參考。一起跟隨小編過來看看吧。

一.創建圖像

創建圖像的一般流程:

1).設定標頭,告訴瀏覽器你要生成的MIME類型。

2).創建一個圖像區域,以后的操作都將基于此圖像區域。

3).在空白圖像區域繪制填充背景。

4).在背景上繪制圖形輪廓輸入文本。

5).輸出最終圖形。

6).清除所有資源。

7).其他頁面調用圖像。

設定標頭指定MIME輸出類型

header('Content-Type: p_w_picpath/png');

?>

創建一個空白的圖像區域

$im= p_w_picpathcreatetruecolor(200,200);

?>

在空白圖像區域繪制填充背景

$blue= p_w_picpathcolorallocate($im,0,102,255);

p_w_picpathfill($im,0,0,$blue);

?>

在背景上繪制圖形輪廓輸入文本

$white= p_w_picpathcolorallocate($im,255,255,255);

p_w_picpathline($im,0,0,200,200,$white);

p_w_picpathline($im,200,0,0,200,$white);

p_w_picpathstring($im,5,80,20,"Mr.Lee",$white);

?>

輸出最終圖形

p_w_picpathpng($im);

?>

清除所有資源

p_w_picpathdestroy($im);

?>

其他頁面調用創建的圖形

二.簡單小案例

簡單驗證碼

header('Content-type: p_w_picpath/png');

//隨機數

for($Tmpa=0;$Tmpa<4;$Tmpa++){

$nmsg.=dechex(rand(0,15));

}

$im= p_w_picpathcreatetruecolor(75,25);

$blue= p_w_picpathcolorallocate($im,0,102,255);

$white= p_w_picpathcolorallocate($im,255,255,255);

p_w_picpathfill($im,0,0,$blue);

p_w_picpathstring($im,5,20,4,$nmsg,$white);

p_w_picpathpng($im);

p_w_picpathdestroy($im);

?>

加載已有的圖像

header('Content-Type:p_w_picpath/png');

define('__DIR__',dirname(__FILE__).'\\');

$im= p_w_picpathcreatefrompng(__DIR__.'222.png');

$white= p_w_picpathcolorallocate($im,255,255,255);

p_w_picpathstring($im,3,5,5,'http://www.yc60.com',$white);

p_w_picpathpng($im);

p_w_picpathdestroy($im);

?>

加載已有的系統字體

$text= iconv("gbk","utf-8","李炎恢");

$font='C:\WINDOWS\Fonts\SIMHEI.TTF';

p_w_picpathttftext($im,20,0,30,30,$white,$font,$text);

?>

圖像微縮

header('Content-type: p_w_picpath/png');

define('__DIR__',dirname(__FILE__).'\\');

list($width,$height) = getp_w_picpathsize(__DIR__.'222.png');

$new_width=$width*0.7;

$new_height=$height*0.7;

$im2= p_w_picpathcreatetruecolor($new_width,$new_height);

$im= p_w_picpathcreatefrompng(__DIR__.'222.png');

p_w_picpathcopyresampled($im2,$im,0,0,0,0,

$new_width,$new_height,$width,$height);

p_w_picpathpng($im2);

p_w_picpathdestroy($im);

Imagedestroy($im2);

?>

看完上訴內容,你們掌握PHP處理圖像的方法了嗎?如果想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!

總結

以上是生活随笔為你收集整理的php 图像 处理,PHP 处理图像步骤解析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。