用GD库来生成缩放图片时质量很差,听说ImageMagick不错,效率快质量高,所以就打算安装来试试。
首先下载ImageMagick源代码,下载地址是:http://www.imagemagick.org/script/download.php
ImageMagick支持很多格式的文件,如常用的gif、jpeg、png、tiff等,在安装ImageMagick前先安装你要支持的文件格式。
开始安装:

./configure --prefix=/usr/local/ImageMagick

执行configure之后,查看哪些格式被支持了,如果你要支持的格式没有被检测到,则可能是你没有安装它,或者它的文件没有被检测到。
我就是安装时检测不到jpeg,png,freetype,但我已经在系统中安装了这些程序,只是ImageMagick没有检测到,上网找了很久也没有找到原因,但有人说查看 config.log 查找原因,后来打开 config.log 文件查找原因,原来是jpeg,png,freetype的库文件和头文件没有被包含进去,后来查了一下,才知道可以用 LDFLAGS和CCPFLAGS来包含库文件和头文件。如我的jpeg源文件在 /usr/local/jpeg-6b ,freetype安装在 /usr/local/freetype,所以在执行configure时加入以下参数

./configure CPPFLAGS="-I/usr/local/jpeg-6b -I/usr/local/freetype/include -I/usr/local/freetype/include/freetype2" LDFLAGS="-L/usr/local/lib -L/usr/local/freetype/lib" --prefix=/usr/local/ImageMagick

如果没有意外,则ImageMagick会检测到jpeg和freetype了

make
make install

Install ImageMagick From Source

Chances are, ImageMagick is already installed on your computer if you are using some flavor of Unix, but that it is not installed if you are using some form of Windows. In either case, you can type the following to find out.

  1. $magick> identify -version ntify -version

If the identify program executes and identifies itself as ImageMagick, you may not need to install ImageMagick from source unless you want to add support for additional image formats or upgrade to a newer version. You also have the option of installing a pre-compiled binary release. However, if you still want to install from source, choose a platform, Unix or Windows. Before installing from source, you may want to review recent changes to the ImageMagick distribution.

Install from Unix Source

ImageMagick builds on a variety of Unix and Unix-like operating systems including Linux, Solaris, FreeBSD, Mac OS X, and others. A compiler is required and fortunately almost all modern Unix systems have one. Download ImageMagick.tar.gz from ftp.imagemagick.org or a mirrors and verify its message digest.

Unpack the distribution with this command:

  1. $magick> tar xvfz ImageMagick.tar.gz 

Next configure and compile ImageMagick:

  1. $magick> cd ImageMagick-6.6.6  
  2. $magick> ./configure
  3. $magick> make 

If ImageMagick configured and compiled without complaint, you are ready to install it on your system. Administrator privileges are required to install. To install, type

  1. $magick> sudo make install 

Finally, verify the ImageMagick install worked properly, type

  1. $magick> /usr/local/bin/convert logo: logo.gif 

For a more comprehensive test, run the ImageMagick validation suite. Ghostscript is a prerequisite, otherwise the EPS, PS, and PDF tests will fail.

  1. $magick> make check 

Congratulations, you have a working ImageMagick distribution and you are ready to use ImageMagick to convert, compose, or edit your images or perhaps you'll want to use one of the Application Program Interfaces for C, C++, Perl, and others.

The above instructions will satisfy a great number of ImageMagick users, but we suspect a few will have additional questions or problems to consider. For example, what does one do if ImageMagick fails to configure or compile? Or what if you don't have administrator privileges and what if you don't want to install ImageMagick in the default /../usr/local folder? You will find the answer to these questions, and more, in Advanced Unix Source Installation.

Install from Windows Source

Building ImageMagick source for Windows requires a modern version of Microsoft Visual Studio IDE. Users have reported success with the Borland C++ compiler as well. If you don't have a compiler you can still install a self-installing binary release.

Download ImageMagick-windows.zip from ftp.imagemagick.org or a mirrors and verify its message digest.

You can unpack the distribution with WinZip or type the following from any MS-DOS Command Prompt window:

  1. $magick> unzip ImageMagick-windows.zip 

Next, launch your Visual Studio IDE and choose Open->Project. Select the configure workspace from the ImageMagick-6.6.6/VisualMagick/configure folder and press Open. Choose Build->Build Solution to compile the program and on completion run the program.

[configure]

Press Next and click on the multi-threaded static build. If you are using the Visual Studio 6.0 IDE, make sure no check is next to the Generate Visual Studio 7 format option. Now press, on Next twice and finally Finish. The configuration utility just created a workspace required to build ImageMagick from source. Choose Open->Project and select the VisualStaticMT workspace from the ImageMagick-6.6.6/VisualMagick/ folder. Finally, choose Build->Build Solution to compile and build the ImageMagick distribution.

To verify ImageMagick is working properly, launch a MS-DOS Command Prompt window and type

  1. $magick> cd ImageMagick-6.6.6
    $magick
    > convert logo: image.jpg 

For a more comprehensive test, run the ImageMagick validation suite:

  1. $magick> validate 

Congratulations, you have a working ImageMagick distribution under Windows and you are ready to use ImageMagick to convert, compose, or edit your images or perhaps you'll want to use one of the Application Program Interfaces for C, C++, Perl, and others.

The above instructions will satisfy a great number of ImageMagick users, but we suspect a few will have additional questions or problems to consider. For example, what does one do if ImageMagick fails to configure or compile? Or what if you want to install ImageMagick in a place other than theImageMagick-6.6.6/VisualMagick/bin folder? Or perhaps you want to build and install the ImageMagickObject COM+ component. You will find the answer to these questions, and more, in Advanced Windows Source Installation.

此文章由 flyinweb 于 2010-12-30 10:33:20 编辑

本日志由 flyinweb 于 2010-12-30 10:06:25 发表,目前已经被浏览 2069 次,评论 0 次;

作者添加了以下标签: ImageMagick

引用通告:http://www.517sou.net/Article/556/Trackback.ashx

评论订阅:http://www.517sou.net/Article/556/Feeds.ashx

相关文章

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)