准备工作
作者:SNAIl_RUN
日期:2008-10-8
转载请注明出处:http://blog.csdn.net/SNAIL_RUN/archive/2008/10/08/3030980.aspx
准备工作 检查
autoconf版本,如果没装请安装,以备phpize出错.
介绍:http://www.gnu.org/software/autoconf/manual/autoconf.txt
下载:
http://ftp.gnu.org/gnu/autocon/autoconf-2.61.tar.gz
- ./configure && make && sudo make install
安装zlib
下载:
- cd /tmp/zlib-1.2.3 //解压目录
- ./configure --prefix=/usr/local/zlib //安装目录
- make && sudo make install //ubuntu下加sudo
安装freetype(一个流行的字体函数库)
介绍:
http://www.freetype.org/
下载:http://sourceforge.net/project/showfiles.php?group_id=3157
- cd /tmp/freetype-2.2.1
- ./configure --prefix=/usr/local/freetype
- make && sudo make install
安装jpeg,让image magick支持jpeg
介绍:http://www.jpeg.org/
下载:http://www.ijg.org/files/jpegsrc.v6b.tar.gz
- ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
- make && sudo make install
安装image-magick
下载:http://www.imagemagick.org/www/download.html
解压后config
- sudo ./configure CPPFLAGS="-I/usr/local/jpeg -I/usr/local/jpeg/include -I/usr/local/freetype/include -I/usr/local/freetype/include/freetype2" LDFLAGS="-L/usr/local/lib -L/usr/local/freetype/lib -L/usr/local/jpeg/lib" --prefix=/usr/local/ImageMagick --disable-openmp
- make && sudo make install
以上须包含jpeg,freetype的相关路径。并禁用openmp,以防止下面的出错
- PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613+lfs/magickwand.so' - libMagickWand.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
在configure后应该显示下面的信息,注意其中的相关选项为yes
- Option Value
- -------------------------------------------------------------------------------
- Shared libraries --enable-shared=yes yes
- Static libraries --enable-static=yes yes
- Module support --with-modules=yes yes
- GNU ld --with-gnu-ld=yes yes
- Quantum depth --with-quantum-depth=16 16
- High Dynamic Range Imagery
- --enable-hdri=no no
- Delegate Configuration:
- BZLIB --with-bzlib=yes no
- Autotrace --with-autotrace=no no
- DJVU --with-djvu=yes no
- DPS --with-dps=yes no
- FlashPIX --with-fpx=yes no
- FontConfig --with-fontconfig=no no
- FreeType --with-freetype=yes yes
- GhostPCL None pcl6 (unknown)
- GhostXPS None gxps (unknown)
- Ghostscript None gs (8.61)
- result_ghostscript_font_dir='none'
- Ghostscript fonts --with-gs-font-dir=default
- Ghostscript lib --with-gslib=yes no
- Graphviz --with-gvc=yes no
- JBIG --with-jbig=yes no
- JPEG v1 --with-jpeg=yes yes
- JPEG-2000 --with-jp2=yes no
- LCMS --with-lcms=yes no
- LQR --with-lqr=yes no
- Magick++ --with-magick-plus-plus=yes yes
- OpenEXR --with-openexr=yes no
- PERL --with-perl=yes /usr/bin/perl
- PNG --with-png=yes yes
- RSVG --with-rsvg=no no
- TIFF --with-tiff=yes no
- result_windows_font_dir='none'
- Windows fonts --with-windows-font-dir=
- WMF --with-wmf=yes no
- X11 --with-x= no
- XML --with-xml=no no
- ZLIB --with-zlib=yes yes
- X11 Configuration:
- X_CFLAGS =
- X_PRE_LIBS =
- X_LIBS =
- X_EXTRA_LIBS =
- Options used to compile and link:
- PREFIX = /usr/local/ImageMagick
- EXEC-PREFIX = /usr/local/ImageMagick
- VERSION = 6.4.4
- CC = gcc -std=gnu99
- CFLAGS = -fopenmp -g -O2 -Wall -W -pthread
- MAGICK_CFLAGS = -fopenmp -g -O2 -Wall -W -pthread
- CPPFLAGS = -I/usr/local/ImageMagick/include/ImageMagick
- PCFLAGS = -fopenmp
- DEFS = -DHAVE_CONFIG_H
- LDFLAGS = -L/usr/local/lib -L/usr/local/freetype/lib -L/usr/local/jpeg/lib
- MAGICK_LDFLAGS = -L/usr/local/ImageMagick/lib -L/usr/local/lib -L/usr/local/freetype/lib -L/usr/local/jpeg/lib
- LIBS = -lMagickCore -lfreetype -ljpeg -lz -lm -lgomp -lpthread
- CXX = g++
- CXXFLAGS = -g -O2 -Wall -W -pthread
中间待补
安装好后进入安装目录:
- cd /usr/local/ImageMagick/bin
压缩jpeg图片
- sudo /usr/local/ImageMagick/bin/convert -quality 90 -resize 100 /tmp/a.jpg /tmp/b.jpg
上面的语句意思是把/tmp/a.jpg图片转化为质量为90的,宽度为100的名为b的jpg图片
压缩gif图片
- sudo ./convert /tmp/1.gif -resize 50x50 /tmp/2.gif
在上面的步骤完成后,下面安装php的imagick扩展.
下载:http://www.magickwand.org/download/php/ 目前最新版本为1.0.7
进入到下载目录,解压
- tar -zxvf MagickWandForPHP-1.0.7.tar.gz
- cd MagickWandForPHP-1.0.7
- sudo /usr/local/php/bin/phpize
- sudo ./configure --with-php-config=/usr/local/php/bin/php-config --with-magickwand=/usr/local/ImageMagick
- make && sudo make install
编译完后显示
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
修改php.ini 如下
; Directory in which the loadable extensions (modules) reside.下面加上目录
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613
"
; extension_dir directive above.//在下面加
extension=magickwand.so
测试:
- a.php
- <?php
- $a = new Imagick();
- ?>
- 1. /usr/local/php/bin/php -f /tmp/a.php
重启apache