Home php教程 php手册 Windows下编译 ImageMagick 的php API

Windows下编译 ImageMagick 的php API

Jun 06, 2016 pm 08:02 PM
api imagemagick php windows compile

首先,需要的软件包有: PHP5.2.5 源码包[http://www.php.net/downloads.php] bindlib_w32 [http://www.php.net/extra/bindlib_w32.zip] win32build [http://www.php.net/extra/win32build.zip] PHP5.2.5 Win32 二进制包 [http://www.php.net/downloads.php]

首先,需要的软件包有:
PHP5.2.5 源码包[http://www.php.net/downloads.php ]
bindlib_w32 [http://www.php.net/extra/bindlib_w32.zip ]
win32build [http://www.php.net/extra/win32build.zip ]
PHP5.2.5 Win32 二进制包 [http://www.php.net/downloads.php ]
ImageMagick 6.3.8-0 Windows版源码 [http://www.imagemagick.org/download/windows/ ]
Imagick 2.1.0RC3 源码包 [http://pecl.php.net/package/imagick ]
MagickWandForPHP 1.0.6 源码包 [http://www.imagemagick.org/download/php/ ]

说明一下:
php源码包就不用说了,编译需要php的源码的。
bindlib_w32 是为了编译一个resolv.lib
win32build是php编译最基本的一些lib文件和include文件。
php的二进制包是因为需要/dev/php5ts.lib文件,当然,你可以选择自己编译生成,但你的工作量将因此增加很多倍。
ImageMagick的windows源码是用来编译windows下的lib文件,同时,编译MagickWand和Imagick都还需要部分源 码。
Imagick是PHP官方提供的一个ImageMagick的扩展,而MagickWandForPHP 则是ImageMagick官方提供的。

此外,还需要一些环境:

Microsoft Visual Studio 6, Cygwin


ok,现在开始。



       建立一个目录 E:/develop,然后分别建立两个子目录,ImageMagick,PHPBuild。将ImageMagick源码直接解压到 ImageMagick目录下;将php5.2.5的源码解压到PHPBuild目录,同时,将bindlib_w32解压到 PHPBuild/bindlib_w32下,win32build 解压到 PHPBuild/win32build 下。


       首先进入ImageMagick/ImageMagick-6.3.8/VisualMagick/configure,用VC6打开 configure.dsw,编译,这样就可以把ImageMagick的编译配置文件生成。生成之后,运行当前目录的configure.exe,第二 页选择Static Multi-threaded DLL runtimes (VisualStaticMTDLL).,Build Options什么都不选。Edit ‘magick-config.h’的根据自己的情况来定。直接下一步,下一步,完成,稍等一会儿,ImageMagick/ImageMagick- 6.3.8/VisualMagick就会生成一个VisualStaticMTDLL.dsw.


        用VC6打开,Build ==> Set Active Configuration…,打开,选择All Release。然后,直接BuildèRebuild All。这个编译的过程耗时较长,所以可以考虑安装官方说明文档的说法,冲杯咖啡,慢慢等。

        编译完成之后,在ImageMagick/ImageMagick-6.3.8/VisualMagick/lib下会有17个以CORE_RL_ 开头的Lib文件,和两个原来就有的X11.lib和Xext.lib。

       将ImageMagick/ImageMagick-6.3.8/和ImageMagick/ImageMagick-6.3.8/magick加入VC 的Include目录里边,将ImageMagick/ImageMagick-6.3.8/VisualMagick/lib加入Lib的目录里。

       接下来,进入PHPBuild/bindlib_w32,用vc打开bindlib.dsw,release编译,将生成的resolv.lib覆盖 PHPBuild/win32build/lib下的同名文件。

解压PHP的二进制版本,并将目录添加到系统环境变量的Path里。
运行Cygwin,进入PHPBuild/php-5.2.5/ext,执行



这样,ext目录下就会生成两个新的目 录,imagick和magickwand,将之前下载的两个扩展的源码分别直接解压覆盖两个目录的同名文件。并将php二进制包的 dev/php5ts.lib分别复制到两个目录中。

       下面就得改dsp文件了。将这些替换原有dsp的相应内容。
magickwand.dsp:

 

 

 

imagick.dsp

因为我只需要Release的dll,所以 Debug部分我没改。(这些内容,参考DIrk的Magickwand的编译以及他提供的dsp文件)

用VC6打开,选择release模式,编译。
成功后将会在PHPBuild/php-5.2.5/Release_TS下生成php_magickwand.dll 和 php_imagick.dll。编译过程就结束了。


PS:
我生成的php_imagick.dll和php_magickwand.dll




UPDATE:

嗯,关于安装,不得不说的
ImageMagick/ImageMagick-6.3.8/config
这个目录是ImageMagick的配置文件
php方面的安装,只要把dll复制到php的ext目录,再修改php.ini,加上extension=php_imagick.dll或 extension=php_magickwand.dll

而配置文件部分
我是将这个config目录复制到了php的二进制文件夹的extra目录,改名为imagemagick_config,主要是方便管理和方便辨识
然后添加一个系统环境变量MAGICK_HOME,指到这个目录即可

 

原文:http://www.bitnp.net/viewthread.php?tid=282291

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the match expression (PHP 8 ) and how it differs from switch. Explain the match expression (PHP 8 ) and how it differs from switch. Apr 06, 2025 am 12:03 AM

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? Apr 07, 2025 am 12:02 AM

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

How to speed up the loading speed of PS? How to speed up the loading speed of PS? Apr 06, 2025 pm 06:27 PM

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

How to distinguish between closing a browser tab and closing the entire browser using JavaScript? How to distinguish between closing a browser tab and closing the entire browser using JavaScript? Apr 04, 2025 pm 10:21 PM

How to distinguish between closing tabs and closing entire browser using JavaScript on your browser? During the daily use of the browser, users may...

How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) How can you prevent a class from being extended or a method from being overridden in PHP? (final keyword) Apr 08, 2025 am 12:03 AM

In PHP, the final keyword is used to prevent classes from being inherited and methods being overwritten. 1) When marking the class as final, the class cannot be inherited. 2) When marking the method as final, the method cannot be rewritten by the subclass. Using final keywords ensures the stability and security of your code.

Describe the purpose and usage of the ... (splat) operator in PHP function arguments and array unpacking. Describe the purpose and usage of the ... (splat) operator in PHP function arguments and array unpacking. Apr 06, 2025 am 12:07 AM

The... (splat) operator in PHP is used to unpack function parameters and arrays, improving code simplicity and efficiency. 1) Function parameter unpacking: Pass the array element as a parameter to the function. 2) Array unpacking: Unpack an array into another array or as a function parameter.

See all articles