在CentOS上安装ImageMagick以及php扩展
http://www.tecmint.com/install-imagemagick-in-linux/
ImageMagick is an free open source simple software suite for any kind of image manipulation that is used for creating, editing, converting, displaying image files. It can able to read and write over 200 image files such as JPEG, GIF, PNG, TIFF and Photo CD image formats and it is also used for thumbnail or captcha generation. It also includes command line options for creating transparent or animated gif image formats and many more feature like resize, sharpen, rotate or add special effects to an image.
To use ImageMagick tool with PHP or Perl programming language, you will need to installImageMagick with Imagick PHP extension for PHP and ImageMagick-perl extension for Perl.
Imagick is an simple php extension for creating and modifying images using the ImageMagick API program. There is a confusion in name, as people think that ImageMagick and Imagickboth are same, but you can use ImageMagick without Imagick extension but you need both installed on your machine to use and run it.
Installing ImageMagick
First, install following prerequisite php-pear and gcc packages to compile imagick PHP extension.
# yum install php-pear gc
c
# yum install php-pear gcc
Once you’ve installed php-pear and gcc packages, you may now install ImageMagick software for PHP and Perl support using Yum command.
# yum install ImageMagick ImageMagick-devel ImageMagick-perl
# yum install ImageMagick ImageMagick-devel ImageMagick-perl
Next, compile the imagick for PHP extension. To do, simple run the following ‘pecl‘ command. It will install ImageMagick and imagick PHP extension module ‘imagick.so‘ under/usr/lib/php/modules directory. If you are using 64-bit system, the module directory path would be /usr/lib64/php/modules.
# pecl install imagick
# pecl install imagick
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading imagick-3.1.0RC2.tgz ...
Starting to download imagick-3.1.0RC2.tgz (93,264 bytes)
.....................done: 93,264 bytes
15 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Please provide the prefix of Imagemagick installation [autodetect] :
Note: It will ask you to provide Imagemagick installation prefix, simply hit enter to auto detect.
Now, add the ‘imagick.so‘ extension to ‘/etc/php.ini‘ file.
echo extension=imagick.so >> /etc/php.ini
echo extension=imagick.so >> /etc/php.ini
Next, restart Apache web server. 这个地方现在一般都是Nginx了,所以应该换成:service nginx restart
# service httpd restart
# service httpd restart
Verify imagick PHP extension by running the following command. You will see imagick extension similar to below.
# php -m | grep imagick
# php -m | grep imagick
imagick
Alternatively, you can create a file called ‘phpinfo.php‘ under website root directory (ex:/var/www/html/).
# vi /var/www/html/phpinfo.php
# vi /var/www/html/phpinfo.php
Add the following code.
<?php
phpinfo ();
?>
<?php
phpinfo ();
?>
Open your favorite web browser and type ‘http://localhost/phpinfo.php‘ or ‘http://ip-addresss/phpinfo.php‘ and verify the imagick extension.
Imagick PHP Extension
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· [AI/GPT/综述] AI Agent的设计模式综述