Home > php教程 > php手册 > PHP image processing (2) GraphicsMagick installation extension and how to use it

PHP image processing (2) GraphicsMagick installation extension and how to use it

WBOY
Release: 2016-07-09 09:10:34
Original
1748 people have browsed it
What is GraphicsMagick?
How to install GraphicsMagick?

PHP Image Processing (1) Introduction and Installation of GraphicsMagick


GraphicsMagick PHP extension installation


Operating system: Centos 5.6
Environment : LAMP
Programming language: PHP
Download address: Gmagick
Related documents: Gmagick

Operation steps

1: Install PHP extension 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
Copy after login



2: Modify the PHP.ini file

<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
Copy after login



3: Display the configuration information of the php server and check whether the extension is installed

<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>?>
Copy after login




How to use GraphicsMagick PHP extension


Operation steps

1: Prepare a picture, does it look like Sun HongleiPHP image processing (2) GraphicsMagick installation extension and how to use it



<?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>?>
Copy after login


<?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>?>
Copy after login


For more methods, please see the relevant documents above


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template