imagemagick介绍:
ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite language. Choose from these interfaces: G2F (Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++),JMagick (Java), L-Magick (Lisp), Lua, NMagick (Neko/haXe), Magick.NET (.NET), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP(PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images dynamically and automagically.
ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may use, copy, modify, and distribute in both open and proprietary applications. It is distributed under the Apache 2.0 license, approved by the OSI and recommended for use by the OSSCC.
The ImageMagick development process ensures a stable API and ABI. Before each ImageMagick release, we perform a comprehensive security assessment that includes memory error and thread data race detection to prevent security vulnerabilities.
The current release is ImageMagick 6.9.0-3 available from http://www.imagemagick.org/download. It runs on Linux, Windows, Mac Os X, iOS, Android OS, and others.
The authoritative ImageMagick web site is http://www.imagemagick.org.
著名的图片服务提供商 Flickr 使用的是ImageMagick,还有 Yupoo 、 手机之家 使用的也是ImageMagick。
下载:http://www.imagemagick.org/download/
windows安装:
下载windows版:
安装后,在安装php扩展:官方推荐的3个:
MagickWand for PHP a native PHP-extension to the ImageMagick MagickWand API.
IMagick is a native PHP extension to create and modify images using the ImageMagick API. Documentation for the extension is available here.
phMagick is a wrapper class for ImageMagick, wrapping the most common web image manipulation actions in easy to use functions, but allowing full access to ImageMagick‘s power by issuing system calls to it‘s command-line programs.
决定使用Imagick。
windows下在iMagick的dll扩展
重命名为php_imagick.dll 然后copy到php的ext文件夹下
在php.ini文件中添加设置
extension=php_imagick.dll
之后查看phpinfo() 里面有没有imagick一栏,如果有的话就可以进行测试了。
参考:http://blog.sina.com.cn/s/blog_966e43000101bgqj.html
LInux安装:
下载源代码:
参考官方教程:
$ cd ImageMagick-6.9.0
$ ./configure
$ make
make install
执行:/usr/local/imagemagick/bin/convert logo: logo.gif 测试一下ImageMagick是否可以正常运行。
或者:convert -version
2、安装PHP扩展:imagick
最新的包可以在下面的地址中找到http://pecl.php.net/package/imagick
1 2 3 4 5 6 7 8 9 10 11 12 |
wget http://pecl.php.net/get/imagick-3.0.1.tgz tar zxvf imagick-3.0.1.tgz cd imagick-3.0.1/ export PKG_CONFIG_PATH=/usr/local/imagemagick/lib/pkgconfig /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick make && make install /usr/local/php_fcgi/bin/phpize |
编辑/usr/local/php/etc/php.ini 添加:extension = "imagick.so"
编辑/usr/local/php_fcgi/etc/php.ini 添加:extension = "imagick.so"
重启php-fpm或apache。
lu-restart
先试试,再执行:ldconfig ,重新加载一些链接库。
(我用的是pecl install imagick 安装,安装完后提示:
You should add "extension=imagick.so" to php.ini
增加就行了。)
php_imagick程序示例
1.创建一个缩略图并显示出来
<?php
header(‘Content-type: image/jpeg‘);
$image = new Imagick(‘image.jpg‘);
// If 0 is provided as a width or height parameter,// aspect ratio is maintained
$image->thumbnailImage(100, 0);
echo $image;
?>
2.创建一个目录下的缩略图,并保存
<?php
$images = new Imagick(glob(‘images
$im = new Imagick("example.gif");
foreach ($im as $frame) {
$frame->thumbnailImage(50, 50);
$frame->setImagePage(50, 50, 0, 0);
}
$im->writeImages("example_small.gif", true);
?>
http://blog.sina.com.cn/s/blog_8da982ac010171iz.html
http://blog.csdn.net/andy1219111/article/details/38335987
http://blog.csdn.net/czloveyeer/article/details/8179766
http://blog.lizhigang.net/archives/228
文档:
http://php.net/manual/zh/book.imagick.php
http://www.bitscn.com/pdb/php/201407/235972.html