当前位置: 首页 > 工具软件 > Magick.NET > 使用案例 >

image-magick安装

洪楷
2023-12-01

准备工作


作者: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

  1. ./configure && make && sudo make install



安装zlib
下载:
  1. cd /tmp/zlib-1.2.3     //解压目录
  2. ./configure --prefix=/usr/local/zlib   //安装目录
  3. make && sudo make install    //ubuntu下加sudo
安装freetype(一个流行的字体函数库)
介绍: http://www.freetype.org/
下载:http://sourceforge.net/project/showfiles.php?group_id=3157
  1. cd /tmp/freetype-2.2.1
  2. ./configure --prefix=/usr/local/freetype
  3. make && sudo make install 
安装jpeg,让image magick支持jpeg
介绍:http://www.jpeg.org/
下载:http://www.ijg.org/files/jpegsrc.v6b.tar.gz
  1. ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
  2. make && sudo make install 

安装image-magick

下载:http://www.imagemagick.org/www/download.html
解压后config
  1. 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
  2. make && sudo make install
以上须包含jpeg,freetype的相关路径。并禁用openmp,以防止下面的出错
  1. 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
  1.               Option                        Value
  2. -------------------------------------------------------------------------------
  3. Shared libraries --enable-shared=yes        yes
  4. Static libraries --enable-static=yes        yes
  5. Module support    --with-modules=yes        yes
  6. GNU ld            --with-gnu-ld=yes            yes
  7. Quantum depth     --with-quantum-depth=16    16
  8. High Dynamic Range Imagery
  9.                   --enable-hdri=no        no
  10. Delegate Configuration:
  11. BZLIB             --with-bzlib=yes        no
  12. Autotrace         --with-autotrace=no        no
  13. DJVU              --with-djvu=yes        no
  14. DPS               --with-dps=yes        no
  15. FlashPIX          --with-fpx=yes        no
  16. FontConfig        --with-fontconfig=no        no
  17. FreeType          --with-freetype=yes        yes
  18. GhostPCL          None                pcl6 (unknown)
  19. GhostXPS          None                gxps (unknown)
  20. Ghostscript       None                gs (8.61)
  21. result_ghostscript_font_dir='none'
  22. Ghostscript fonts --with-gs-font-dir=default   
  23. Ghostscript lib   --with-gslib=yes        no
  24. Graphviz          --with-gvc=yes        no
  25. JBIG              --with-jbig=yes        no
  26. JPEG v1           --with-jpeg=yes        yes
  27. JPEG-2000         --with-jp2=yes        no
  28. LCMS              --with-lcms=yes        no
  29. LQR               --with-lqr=yes        no
  30. Magick++          --with-magick-plus-plus=yes    yes
  31. OpenEXR           --with-openexr=yes        no
  32. PERL              --with-perl=yes        /usr/bin/perl
  33. PNG               --with-png=yes        yes
  34. RSVG              --with-rsvg=no        no
  35. TIFF              --with-tiff=yes        no
  36. result_windows_font_dir='none'
  37. Windows fonts     --with-windows-font-dir=   
  38. WMF               --with-wmf=yes        no
  39. X11               --with-x=                no
  40. XML               --with-xml=no        no
  41. ZLIB              --with-zlib=yes        yes
  42. X11 Configuration:
  43.       X_CFLAGS        =
  44.       X_PRE_LIBS      =
  45.       X_LIBS          =
  46.       X_EXTRA_LIBS    =
  47. Options used to compile and link:
  48. PREFIX          = /usr/local/ImageMagick
  49. EXEC-PREFIX     = /usr/local/ImageMagick
  50. VERSION         = 6.4.4
  51. CC              = gcc -std=gnu99
  52. CFLAGS          = -fopenmp -g -O2 -Wall -W -pthread
  53. MAGICK_CFLAGS   = -fopenmp -g -O2 -Wall -W -pthread
  54. CPPFLAGS        = -I/usr/local/ImageMagick/include/ImageMagick
  55. PCFLAGS         = -fopenmp
  56. DEFS            = -DHAVE_CONFIG_H
  57. LDFLAGS         = -L/usr/local/lib -L/usr/local/freetype/lib -L/usr/local/jpeg/lib
  58. MAGICK_LDFLAGS = -L/usr/local/ImageMagick/lib -L/usr/local/lib -L/usr/local/freetype/lib -L/usr/local/jpeg/lib
  59. LIBS            = -lMagickCore -lfreetype -ljpeg -lz -lm -lgomp -lpthread
  60. CXX             = g++
  61. CXXFLAGS        = -g -O2 -Wall -W -pthread

中间待补
安装好后进入安装目录:
  1. cd /usr/local/ImageMagick/bin
压缩jpeg图片
  1. sudo /usr/local/ImageMagick/bin/convert -quality 90 -resize 100 /tmp/a.jpg /tmp/b.jpg
上面的语句意思是把/tmp/a.jpg图片转化为质量为90的,宽度为100的名为b的jpg图片


压缩gif图片
  1. sudo ./convert /tmp/1.gif -resize 50x50 /tmp/2.gif


在上面的步骤完成后,下面安装php的imagick扩展.
下载:http://www.magickwand.org/download/php/ 目前最新版本为1.0.7
进入到下载目录,解压
  1. tar -zxvf MagickWandForPHP-1.0.7.tar.gz
  2. cd MagickWandForPHP-1.0.7
  3. sudo /usr/local/php/bin/phpize 
  4. sudo ./configure --with-php-config=/usr/local/php/bin/php-config --with-magickwand=/usr/local/ImageMagick
  5. 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
测试:
  
  1. a.php
  2. <?php
  3.     $a = new Imagick();
  4. ?>
  5. 1. /usr/local/php/bin/php -f /tmp/a.php 

重启apache

 类似资料: