最近的PHP项目中,需要用到切图和缩图的效果,在linux测试服务器上很轻松的就安装好php imagick扩展。但是在本地windows开发环境,安装过程遇到好多问题,在此与大家分享。
1. 下载 ImageMagick
下载地址:http://imagemagick.org/script/binary-releases.php#windows
下载最新版本,ImageMagick-6.8.6-9-Q16-x86-dll.exe
2. 安装 ImageMagick
安装 ImageMagick 到 PC 上。安装路径不能出现空格,否则无法使用。安装时,一点选中把执行路径添加到 path 上,否则你就得手动去添加 path 路径了。
3. 测试安装
打开windows 命令行窗口(win+r -> “cmd” -> Enter),输入convert,回车。会出现convert的帮助文档,如果没有出现,说明没有安装成功,或没有把安装目录添加到环境变量 path 中。
添加到环境变量,如我的 ImageMagick 安装目录是 c:/imagemagick。
添加过程:
我的电脑 -> 右键点击 -> 高级系统设置 -> 高级 -> 环境变量 -> 系统变量 -> path -> 选择并编辑 -> 把你的安装目录,添加到其中
4. 下载 php扩展 php_imagick.dll
php5.4.x or php5.5.x 下载地址 http://www.peewit.fr/imagick/
dyn = dynamic, st = static, q16 = 16 bit, q8= 8 bit.
以上标识,同你下载的ImageMagick下载标识相同,本人用的是q16
5. 把dll文件重命名为php_imagick.dll,并放到php 扩展文件目录 php/ext 中。
6. 在 php.ini 配置文件中添加,extension=php_imagick.dll。
7. 重启电脑,只重启apache不管用的情况下,重启下PC。因为扩展底层使用的是imageMagic软件,所以软件重启电脑,重新加载软件,并刷新path路径。
8. 重启后,打开 phpinfo页面,查看,扩展已经安装成功。如果还未安装成功,极有可能imagemagick软件版本过高,请选择更低一级的版本安装。
9. PHP测试代码。
<?php $im = new imagick( 'a.jpg' ); // resize by 200 width and keep the ratio $im->thumbnailImage( 200, 0); // write to disk $im->writeImage( 'a_thumbnail.jpg' );
10. 查看手册,学习API
相关扩展学习手册地址 http://uk3.php.net/manual/zh/book.imagick.php 手册中包含大量易用实例。
这里还有查看命令行参数的文档 http://www.imagemagick.org/Usage/

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version
God-level code editing software (SublimeText3)