PHP 图像处理
<div id="article_content" class="article_content clearfix"><link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
<div id="content_views" class="htmledit_views">
<p>PHP 提供了丰富的图像处理函数,主要包括:</p>
<table><tbody><tr><th>函数</th><th>描述</th></tr><tr><td><ahref="https://www.runoob.com/php/php-gd-info.html">gd_info()</a></td><td>取得当前安装的 GD 库的信息</td></tr><tr><td><ahref="https://www.runoob.com/php/php-getimagesize.html">getimagesize()</a></td><td>获取图像信息</td></tr><tr><td><ahref="https://www.runoob.com/php/php-getimagesizefromstring.html">getimagesizefromstring()</a></td><td>获取图像信息</td></tr><tr><td><ahref="https://www.runoob.com/php/php-image-type-to-extension.html">image_type_to_extension()</a></td><td>获取图片后缀</td></tr><tr><td><ahref="https://www.runoob.com/php/php-image2wbmp.html">image_type_to_mime_type()</a></td><td>返回图像的 MIME 类型</td></tr><tr><td><ahref="https://www.runoob.com/php/php-image2wbmp.html">image2wbmp()</a></td><td>输出WBMP图片</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imageaffine.html">imageaffine()</a></td><td>返回经过仿射变换后的图像</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imageaffinematrixconcat.html">imageaffinematrixconcat()</a></td><td>连接两个矩阵</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imageaffinematrixget.html">imageaffinematrixget()</a></td><td>获取矩阵</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagealphablending.html">imagealphablending()</a></td><td>设定图像的混色模式</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imageantialias.html">imageantialias()</a></td><td>是否使用抗锯齿(antialias)功能</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagearc.html">imagearc()</a></td><td>画椭圆弧</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagechar.html">imagechar()</a></td><td>写出横向字符</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagecharup.html">imagecharup()</a></td><td>垂直地画一个字符</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagecolorallocate.html">imagecolorallocate()</a></td><td>为一幅图像分配颜色</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagecolorallocatealpha.html">imagecolorallocatealpha()</a></td><td>为一幅图像分配颜色和透明度</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagecolorat.html">imagecolorat()</a></td><td>取得某像素的颜色索引值</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagecolorclosest.html">imagecolorclosest()</a></td><td>取得与指定的颜色最接近的颜色的索引值</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagecolorclosestalpha.html">imagecolorclosestalpha()</a></td><td>取得与指定的颜色加透明度最接近的颜色的索引</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagecolorclosesthwb.html">imagecolorclosesthwb()</a></td><td>取得与指定的颜色最接近的色度的黑白色的索引</td></tr><tr><td><ahref="https://www.runoob.com/php/php-imagesx-imagesy.html">imagesx() 、imagesy()</a></td><td>获取图像宽度与高度</td></tr></tbody></table>
<h2>GD 库</h2>
<p>使用 PHP 图像处理函数,需要加载 GD 支持库。请确定 php.ini 加载了 GD 库:</p>
<p>Window 服务器上:</p>
<pre>extension = php_gd2.dll</pre>
<p>Linux 和 Mac 系统上:</p>
<pre>extension = php_gd2.so</pre>
<p>使用 gd_info() 函数可以查看当前安装的 GD 库的信息:</p>
<pre><?php
var_dump(gd_info());
?></pre>
<p>输出大致如下:</p>
<pre>array(12) {
["GD Version"]=>
string(26) "bundled (2.1.0 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["T1Lib Support"]=>
bool(false)
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(false)
["XBM Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}</pre>
</div>
</div>
<div id="treeSkill"></div>
页:
[1]