Heim  >  Artikel  >  php教程  >  PHP图像处理(二) GraphicsMagick 安装扩展及使用方法

PHP图像处理(二) GraphicsMagick 安装扩展及使用方法

WBOY
WBOYOriginal
2016-07-09 09:10:341705Durchsuche
什么是GraphicsMagick? 
如何安装GraphicsMagick?

PHP图像处理(一) GraphicsMagick介绍与安装


GraphicsMagick PHP扩展安装


操作系统  : Centos 5.6
环境        : LAMP
编程语言  : PHP
下载地址  : Gmagick
相关文档  : Gmagick

 

操作步骤

1 : 安装PHP扩展 gmagick-1.0.9

<span style="line-height: 1.5; font-size: 12px; color: #008000;"># </span><span style="line-height: 1.5; font-size: 12px; color: #008000;">安装扩展</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"><br></span>tar -zxvf gmagick-1.0.9b1.tgz<br>cd gmagick-1.0.9b1<br>/usr/local/php/bin/phpize<br>./configure --with-php-config=/usr/local/php/bin/php-config<br>make <br>make install



2 : 修改PHP.ini文件

<span style="line-height: 1.5; font-size: 12px; color: #008000;">#</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"> 修改配置文件</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"><br></span>vi /usr/local/php/etc/php.ini<br><span style="line-height: 1.5; font-size: 12px; color: #008000;">#</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"> extension_dir = './' 更改路径</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"><br></span>extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/gmagick.so"<br><span style="line-height: 1.5; font-size: 12px; color: #008000;">#</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"> 开启gmagick扩展</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"><br></span>extension = gmagick.so<br><span style="line-height: 1.5; font-size: 12px; color: #008000;">#</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"> 重启Apache</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"><br></span>/usr/local/apache2/bin/apachectl restart



3 : 显示php服务器的配置信息,查看扩展是否安装

<span style="line-height: 1.5; font-size: 12px; color: #008000;">#</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"> 创建文件</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"><br></span>vi /usr/local/apache2/htdocs/index.php<br><span style="line-height: 1.5; font-size: 12px; color: #008000;">#</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"> 写入</span><span style="line-height: 1.5; font-size: 12px; color: #008000;"><br></span><?php <br>     <span style="line-height: 1.5; font-size: 12px; color: #008080;">phpinfo</span>();<br>?>




GraphicsMagick PHP扩展使用方法


操作步骤

1 : 准备一张图片,象不象孙红雷PHP图像处理(二) GraphicsMagick 安装扩展及使用方法



<?php <br><span style="color: #008000;">#</span><span style="color: #008000;"> 如果使用扩展报错请安装libpng ,libjpeg ,libmcrypt到默认目录</span><span style="color: #008000;"><br></span><br><span style="color: #800080;">$image</span> = <span style="color: #0000ff;">new</span> Gmagick('1.jpg');<br><br><span style="color: #800080;">$image</span>->borderImage('blue',3,3)->oilPaintImage(0.1);<br><br><span style="color: #800080;">$image</span>->write('2.jpg');<br>?>


<?php <br><span style="color: #800080;">$image</span> = <span style="color: #0000ff;">new</span> Gmagick('1.jpg');<br><br><span style="color: #008000;">//</span><span style="color: #008000;"> 改变图片大小</span><span style="color: #008000;"><br></span><span style="color: #800080;">$image</span>->resizeimage(100,200);<br><br><span style="color: #800080;">$image</span>->write('2.jpg');<br>?>


更多方法请看上面的相关文档


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn