window8安装imagick convert为什么没有convert

是一个的扩展,用提供的API来进行图片的创建与修改,不过这些操作已经包装到扩展imagick中去了,最终调用的是ImageMagick提供的APIImageMagick是一套软件系列,主要用于图片的创建、编辑以及转换等,详细的解释见ImageMagick的官方网站,ImageMagick与GD的性能要高很多,如果是在处理大量的图片时更加能体现ImageMagick的性能。英文原文介绍如下:imagick is a native php extension to create and modify images using the ImageMagick API.&ImageMagick is a software suite to create, edit, and compose bitmap images.. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF.&著名的图片服务提供商使用的是ImageMagick,还有、使用的也是ImageMagick。1.安装ImageMagick
这里主要说说Linux下的安装,Windows下的安装就不说了,Windows下的安装相对简单一些,参考由于安装imagick扩展时需要依赖ImageMagick的函数库,因此必须要先安装ImageMagick从地址ftp://ftp.imagemagick.org/pub/ImageMagick/可以找到ImageMagick的地址[root@CentOS_Test_Server software]# wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.5.3-10.tar.gz--19:26:09--& ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.5.3-10.tar.gz&&&&&&&&&& =& `ImageMagick-6.5.3-10.tar.gz'正在解析主机 ftp.imagemagick.org... 74.63.13.227Connecting to ftp.imagemagick.org|74.63.13.227|:21... 已连接。正在以 anonymous 登录 ... 登录成功!==& SYST ... 完成。&&& ==& PWD ... 完成。==& TYPE I ... 完成。& ==& CWD /pub/ImageMagick ... 完成。==& SIZE ImageMagick-6.5.3-10.tar.gz ... ==& PASV ... 完成。&&& ==& RETR ImageMagick-6.5.3-10.tar.gz ... 完成。长度:M)100%[=====================================================================================&] 11,151,919& 33.4K/s&& in 3m 9s19:29:42 (57.7 KB/s) - `ImageMagick-6.5.3-10.tar.gz' saved []tar zxvf ImageMagick-6.5.3-10.tar.gzcd ImageMagick-6.5.3-10./configure --prefix=/usr/local/imagemagickmakemake installImageMagick安装完成以后的目录结构如下:[root@CentOS_Test_Server imagemagick]# pwd/usr/local/imagemagick[root@CentOS_Test_Server imagemagick]# ll总计 32drwxr-xr-x 2 root root
19:59 bindrwxr-xr-x 3 root root
20:02 includedrwxr-xr-x 4 root root
20:07 libdrwxr-xr-x 5 root root
20:07 sharebin目录下的这些命令都可以通过命令行方式来操作图片[root@CentOS_Test_Server imagemagick]# ll bin/总计 356-rwxr-xr-x 1 root root
19:59 animate-rwxr-xr-x 1 root root
19:59 compare-rwxr-xr-x 1 root root
19:59 composite-rwxr-xr-x 1 root root
19:59 conjure-rwxr-xr-x 1 root root
19:59 convert-rwxr-xr-x 1 root root
19:59 display-rwxr-xr-x 1 root root
19:59 identify-rwxr-xr-x 1 root root
19:59 import-rwxr-xr-x 1 root root&
19:59 Magick-config-rwxr-xr-x 1 root root&
19:59 Magick++-config-rwxr-xr-x 1 root root&
19:59 MagickCore-config-rwxr-xr-x 1 root root&
19:59 MagickWand-config-rwxr-xr-x 1 root root
19:59 mogrify-rwxr-xr-x 1 root root
19:59 montage-rwxr-xr-x 1 root root
19:59 stream-rwxr-xr-x 1 root root&
19:59 Wand-config[root@CentOS_Test_Server imagemagick]# ll include/总计 8drwxr-xr-x 5 root root
20:07 ImageMagick[root@CentOS_Test_Server imagemagick]# ll include/ImageMagick/总计 32drwxr-xr-x 2 root root
20:07 magickdrwxr-xr-x 2 root root
20:07 Magick++-rw-r--r-- 1 root root& 419 07-21 20:07 Magick++.hdrwxr-xr-x 2 root root
20:07 wand[root@CentOS_Test_Server imagemagick]# ll lib/总计 17884drwxr-xr-x 4 root root&&&
20:02 ImageMagick-6.5.3-rw-r--r-- 1 root root -21 19:59 libMagick++.a-rw-r--r-- 1 root root -21 19:59 libMagickCore.a-rwxr-xr-x 1 root root&&&
19:59 libMagickCore.lalrwxrwxrwx 1 root root&&&&& 22 07-21 19:59 libMagickCore.so -& libMagickCore.so.2.0.0lrwxrwxrwx 1 root root&&&&& 22 07-21 19:59 libMagickCore.so.2 -& libMagickCore.so.2.0.0-rwxr-xr-x 1 root root -21 19:59 libMagickCore.so.2.0.0-rwxr-xr-x 1 root root&&&
19:59 libMagick++.lalrwxrwxrwx 1 root root&&&&& 20 07-21 19:59 libMagick++.so -& libMagick++.so.2.0.0lrwxrwxrwx 1 root root&&&&& 20 07-21 19:59 libMagick++.so.2 -& libMagick++.so.2.0.0-rwxr-xr-x 1 root root -21 19:59 libMagick++.so.2.0.0-rw-r--r-- 1 root root -21 19:59 libMagickWand.a-rwxr-xr-x 1 root root&&&
19:59 libMagickWand.lalrwxrwxrwx 1 root root&&&&& 22 07-21 19:59 libMagickWand.so -& libMagickWand.so.2.0.0lrwxrwxrwx 1 root root&&&&& 22 07-21 19:59 libMagickWand.so.2 -& libMagickWand.so.2.0.0-rwxr-xr-x 1 root root -21 19:59 libMagickWand.so.2.0.0drwxr-xr-x 2 root root&&&
20:07 pkgconfig通过命令man ImageMagick可以查看ImageMagick手册的内容,特别要注意ImageMagick中的大小写,不要写错了2.安装PHP的扩展imagick
安装imagick扩展时需要PHP &= 5.1.3,ImageMagick &= 6.2.4从找到imagick的最新的stable版本[root@CentOS_Test_Server software]# wget http://pecl.php.net/get/imagick-2.2.2.tgz--23:08:04--& http://pecl.php.net/get/imagick-2.2.2.tgz正在解析主机 pecl.php.net... 216.92.131.66Connecting to pecl.php.net|216.92.131.66|:80... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:77212 (75K) [application/octet-stream]Saving to: `imagick-2.2.2.tgz.1'100%[=====================================================================================&] 77,212&&&&& 35.1K/s&& in 2.1s23:08:08 (35.1 KB/s) - `imagick-2.2.2.tgz.1' saved []cd imagick-2.2.2用tar zxvf解压.tgz文件时报错,网上说的也是这么解压,还是不行啊,不知道解压报错跟什么有关[root@CentOS_Test_Server software]# tar zxvf imagick-2.2.2.tgzpackage.xmlimagick-2.2.2/examples/polygon.phpimagick-2.2.2/examples/captcha.phpimagick-2.2.2/examples/thumbnail.phpimagick-2.2.2/examples/watermark.phpimagick-2.2.2/config.m4imagick-2.2.2/config.w32imagick-2.2.2/CREDITSimagick-2.2.2/imagick.cimagick-2.2.2/imagick_class.cgzip: stdin: invalid compressed data--format violatedtar: 归档文件中异常的 EOFtar: 归档文件中异常的 EOFtar: 错误不可恢复:现在退出phpize是一个shell脚本,主要是用来进行编译环境的准备,执行以后会生成一些新的文件,为配置、编译及安装作好准备[root@CentOS_Test_Server imagick-2.2.2]# /usr/local/webserver/php/bin/phpizeConfiguring for:PHP Api Version:&&&&&&&& Zend Module Api No:&&&&& Zend Extension Api No:&& 执行phpize命令以前目录imagick-2-2-2中的内容[root@CentOS_Test_Server imagick-2.2.2]# ll总计 260-rw-r--r-- 1 root root&&
06:11 config.m4-rw-r--r-- 1 root root&&
06:11 config.w32-rw-r--r-- 1 root root&&&& 39 02-07 06:11 CREDITSdrwxr-xr-x 2 root root&&
23:09 examples-rw-r--r-- 1 root root&
06:11 imagick.c-rw-r--r-- 1 root root -21 23:09 imagick_class.c执行phpize命令以后目录imagick-2-2-2中的内容[root@CentOS_Test_Server imagick-2.2.2]# ll总计 1504-rw-r--r-- 1 root root&
23:12 acinclude.m4-rw-r--r-- 1 root root -21 23:12 aclocal.m4drwxr-xr-x 2 root root&&
23:12 autom4te.cachedrwxr-xr-x 2 root root&&
23:12 build-rwxr-xr-x 1 root root&
23:12 config.guess-rw-r--r-- 1 root root&&
23:12 config.h.in-rw-r--r-- 1 root root&&
06:11 config.m4-rwxr-xr-x 1 root root&
23:12 config.sub-rwxr-xr-x 1 root root -21 23:12 configure-rw-r--r-- 1 root root&&
23:12 configure.in-rw-r--r-- 1 root root&&
06:11 config.w32-rw-r--r-- 1 root root&&&& 39 02-07 06:11 CREDITSdrwxr-xr-x 2 root root&&
23:09 examples-rw-r--r-- 1 root root&
06:11 imagick.c-rw-r--r-- 1 root root -21 23:09 imagick_class.c-rw-r--r-- 1 root root&&&&& 0 07-21 23:12 install-sh-rw-r--r-- 1 root root -21 23:12 ltmain.sh-rw-r--r-- 1 root root&&
23:12 Makefile.global-rw-r--r-- 1 root root&&&&& 0 07-21 23:12 missing-rw-r--r-- 1 root root&&&&& 0 07-21 23:12 mkinstalldirs-rw-r--r-- 1 root root&
23:12 run-tests.php让我们来看看imagick的扩展的配置选项[root@CentOS_Test_Server imagick-2.2.2]# ./configure --help | more`configure' configures this package to adapt to many kinds of systems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them asVAR=VALUE.& See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:& -h, --help&&&&&&&&&&&&& display this help and exit&&&&& --help=short&&&&&&& display options specific to this package&&&&& --help=recursive&&& display the short help of all the included packages& -V, --version&&&&&&&&&& display version information and exit& -q, --quiet, --silent&& do not print `checking...' messages&&&&& --cache-file=FILE&& cache test results in FILE [disabled]& -C, --config-cache&&&&& alias for `--cache-file=config.cache'& -n, --no-create&&&&&&&& do not create output files&&&&& --srcdir=DIR&&&&&&& find the sources in DIR [configure dir or `..']Installation directories:& --prefix=PREFIX&&&&&&&& install architecture-independent files in PREFIX&&&&&&&&&&&&&&&&&&&&&&&&& [/usr/local]& --exec-prefix=EPREFIX&& install architecture-dependent files in EPREFIX&&&&&&&&&&&&&&&&&&&&&&&&& [PREFIX]By default, `make install' will install all the files in`/usr/local/bin', `/usr/local/lib' etc.& You can specifyan installation prefix other than `/usr/local' using `--prefix',for instance `--prefix=$HOME'.For better control, use the options below.Fine tuning of the installation directories:& --bindir=DIR&&&&&&&&&& user executables [EPREFIX/bin]& --sbindir=DIR&&&&&&&&& system admin executables [EPREFIX/sbin]& --libexecdir=DIR&&&&&& program executables [EPREFIX/libexec]& --datadir=DIR&&&&&&&&& read-only architecture-independent data [PREFIX/share]& --sysconfdir=DIR&&&&&& read-only single-machine data [PREFIX/etc]& --sharedstatedir=DIR&& modifiable architecture-independent data [PREFIX/com]& --localstatedir=DIR&&& modifiable single-machine data [PREFIX/var]& --libdir=DIR&&&&&&&&&& object code libraries [EPREFIX/lib]& --includedir=DIR&&&&&& C header files [PREFIX/include]& --oldincludedir=DIR&&& C header files for non-gcc [/usr/include]& --infodir=DIR&&&&&&&&& info documentation [PREFIX/info]& --mandir=DIR&&&&&&&&&& man documentation [PREFIX/man]System types:& --build=BUILD&&&& configure for building on BUILD [guessed]& --host=HOST&&&&&& cross-compile to build programs to run on HOST [BUILD]& --target=TARGET&& configure for building compilers for TARGET [HOST]Optional Features:& --disable-FEATURE&&&&&& do not include FEATURE (same as --enable-FEATURE=no)& --enable-FEATURE[=ARG]& include FEATURE [ARG=yes]& --enable-shared=PKGS& build shared libraries default=yes& --enable-static=PKGS& build static libraries default=yes& --enable-fast-install=PKGS& optimize for fast installation default=yes& --disable-libtool-lock& avoid locking (might break parallel builds)Optional Packages:& --with-PACKAGE[=ARG]&&& use PACKAGE [ARG=yes]& --without-PACKAGE&&&&&& do not use PACKAGE (same as --with-PACKAGE=no)&&--with-libdir=NAME&&&&& Look for libraries in .../NAME rather than .../lib& --with-php-config=PATH& Path to php-config php-config&--with-imagick=DIR&&&& Enables the imagick extension. DIR is the prefix to Imagemagick installation directory.&--with-imagick-gm=DIR& GraphicsMagick backend. NO LONGER SUPPORTED!& --with-gnu-ld&&&&&&&&&& assume the C compiler uses GNU ld default=no& --with-pic&&&&&&&&&&&&& try to use only PIC/non-PIC objects default=use both& --with-tags=TAGS&&&&& include additional configurations automaticSome influential environment variables:& CC&&&&&&&&& C compiler command& CFLAGS&&&&& C compiler flags& LDFLAGS&&&& linker flags, e.g. -L&lib dir& if you have libraries in a&&&&&&&&&&&&& nonstandard directory &lib dir&& CPPFLAGS&&& C/C++ preprocessor flags, e.g. -I&include dir& if you have&&&&&&&&&&&&& headers in a nonstandard directory &include dir&& CPP&&&&&&&& C preprocessorUse these variables to override the choices made by `configure' or to helpit to find libraries and programs with nonstandard names/locations../configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-imagick=/usr/local/imagemagick编译过程中如果报错,则通过ln -s把ImageMagick的so及la文件链接到/usr/lib目录下,如果不报错,则不需要做链接,我原来是由于安装包不对,导致用tar zxvf解压的时候文件解出来的不全,例如一些.h文件都没有解压出来,所以编译当然会报错了,因此我才加了下面这些链接,后来编译还是报错。[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickCore.so /usr/lib/libMagickCore.so[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickCore.so.2 /usr/lib/libMagickCore.so.2[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickCore.la /usr/lib/libMagickCore.la[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagick++.so /usr/lib/libMagick++.so[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagick++.so.2 /usr/lib/libMagick++.so.2[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagick++.la /usr/lib/libMagick++.la[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickWand.so /usr/lib/libMagickWand.so[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickWand.so.2 /usr/lib/libMagickWand.so.2[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickWand.la /usr/lib/libMagickWand.la[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickCore.so.2.0.0 /usr/lib/libMagickCore.so.2.0.0[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagick++.so.2.0.0 /usr/lib/libMagick++.so.2.0.0[root@CentOS_Test_Server lib]# ln -s /usr/local/imagemagick/lib/libMagickWand.so.2.0.0 /usr/lib/libMagickWand.so.2.0.0make小记编译imagick扩展遇到的郁闷的问题由于原来在目录/home/software下已经有文件imagick-2.2.2.tgz,这个文件是在vista下面下载后,通过Vmware共享给CentOS的,后来我通过wget又下载了一个,很巧的是也同样还是这个版本,文件名一模一样,因此新下载的imagick扩展自动命名为imagick-2.2.2.tgz.1,wget的下载日志&23:08:08 (35.1 KB/s) - `imagick-2.2.2.tgz.1' saved []&,解压的时候解的仍然是vista下面下载的那个文件,因此导致解压的时候报错,解压出来的文件不全,因此导致编译报错,可能是与安装包的格式有关吧,参考,与这个有点类似吧,通过wget下载的安装包应该是不会出现这个问题的,然后rm imagick-2.2.2.tgz,mv imagick-2.2.2.tgz.1 imagick-2.2.2.tgz,tar zxvf imagick-2.2.2.tgz,解压后正常,说明是安装包的问题,然后后来的一切就都正常了。make install也就是把编译生成的so文件拷贝到php的扩展目录下[root@CentOS_Test_Server imagick-2.2.2]# make install/bin/sh /home/software/imagick-2.2.2/libtool --mode=install cp ./imagick.la /home/software/imagick-2.2.2/modulescp ./.libs/imagick.so /home/software/imagick-2.2.2/modules/imagick.socp ./.libs/imagick.lai /home/software/imagick-2.2.2/modules/imagick.laPATH="$PATH:/sbin" ldconfig -n /home/software/imagick-2.2.2/modules----------------------------------------------------------------------Libraries have been installed in:&& /home/software/imagick-2.2.2/modulesIf you ever happen to want to link against installed librariesin a given directory, LIBDIR, you must either use libtool, andspecify the full pathname of the library, or use the `-LLIBDIR'flag during linking and do at least one of the following:&& - add LIBDIR to the `LD_LIBRARY_PATH' environment variable&&&& during execution&& - add LIBDIR to the `LD_RUN_PATH' environment variable&&&& during linking&& - use the `-Wl,--rpath -Wl,LIBDIR' linker flag&& - have your system administrator add LIBDIR to `/etc/ld.so.conf'See any operating system documentation about shared libraries formore information, such as the ld(1) and ld.so(8) manual pages.----------------------------------------------------------------------Installing shared extensions:&&&& /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-/查看so文件是否已经生成,发现imagick.so文件已经在php的扩展目录下面了,证明已经安装成功[root@CentOS_Test_Server imagick-2.2.2]# ll /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-/总计 3040-rwxr-xr-x 1 root root& -17 19:07 db4.so-rwxr-xr-x 1 root root& -28 20:55 eaccelerator.so-rwxr-xr-x 1 root root& -22 03:30 imagick.so-rwxr-xr-x 1 root root& -28 20:38 memcache.so-rwxr-xr-x 1 root root& -28 22:23 pdo_mysql.so-rwxr-xr-x 1 root root -08 19:10 xapian.so3.相关配置
vi /usr/local/webserver/php/etc/php.ini,加入如下的一行extension = "imagick.so"然后执行php -m | grep imagick,发现已经出现imagick模块了,证明imagick已经生效了[root@CentOS_Test_Server imagick-2.2.2]# php -m | grep imagickimagick上面只是命令行生效了,为了让web服务器也生效,必须要重启php-fpm(我的环境是Nginx+fastcgi方式执行的php)[root@CentOS_Test_Server imagick-2.2.2]# /usr/local/webserver/php/sbin/php-fpm restartShutting down php_fpm . doneStarting php_fpm& donevi index.php,输入如下的内容&?phpphpinfo()?&在浏览器执行index.php即可看到模块imagick已经生效4.测试
PHP的imagick安装以后,提供4个PHP的图片处理类,分别是Imagick、ImagickDraw、ImagickPixel、ImagickPixelIterator,可以参考PHP的英文手册(一般指的是chm格式的手册,可以下载到本地查阅)或者在线手册()可以用两种方式进行调用,一种方式是直接调用/usr/local/imagemagick/bin目录下的命令,第二种方式是调用PHP的imagick扩展提供的api测试一,通过php扩展进行调用vi /home/htdocs/www/imagick_test1.php,输入如下的代码&?phpheader('Content-type: image/jpeg');$image = new Imagick('old_s.jpg');// If 0 is provided as a width or height parameter,// aspect ratio is maintained$image-&thumbnailImage(100, 0);echo $?&然后在浏览中执行,即可看到一张100px & 80px的图片,old_s是大S的意思,也就是我是用大S的照片做的测试,在这里就不截图了,其它的例子大家看手册基本就会用了另外可以在上述文件中的第一行加入判断模块imagick已经安装或加载的代码,extension_loaded('imagick') or die('imagick not loaded');测试二,通过命令行进行调用进入到图片所在目录cd /home/htdocs/www/usr/local/imagemagick/bin/convert old_s.jpg -resize 50% old_s.png原来的图片old_s.jpg是800*640,转换后生成的图片old_s.png是400*320,刚好减少一半每个命令的选项少的有几十个,多的则有上百个选项,非常复杂,功能非常的强大,参考另外,Discuz采用了ImageMagick及GD两种方式来处理图片,Discuz7.0版本有个文件Discuz_7.0.0_SC_GBK/upload/include/image.class.php,基中的方法Thumb_IM及Watermark_IM使用的就是ImageMagick,大家可以参考一下Discuz的代码。BTW:我写这篇博客是用的笔记本电脑的电池,因为有一段时间没有用笔记本电脑的电池了,以后每月尽量充放电一次,以保持电池的容量,电池大概用了二个小时零10分钟吧,还算可以参考:ImageMagick百度百科:ImageMagick中文站:ImageMagick英文站:imagemagick安装英文文档:ImageMagick的ftp下载地址:ImageMagick的api:&ImageMagick的命令行参考文档:ImageMagick的PHP手册:ImageMagick的PHP扩展:
阅读(...) 评论()5400人阅读
综合(31)
imagemagick文档:
convert功能强大,用来批处理图片的放大、缩小、裁剪、旋转、合并、水印、拼接、格式转换等都非常方便,特别适合后台的图片处理。
1,获取图片信息
$identify image.png
image.png PNG 559x559 559x559+0+0 8-bit sRGB 467KB 0.000u 0:00.008
如果只需要获取宽高:
$identify -format &%wx%h& image.png
2,放大,缩小 -resize
$convert image.png -resize 200x200 resize.png
也可以按照比例(缩小一半):
$convert image.png -resize 50% resize.png
还可以多次缩放(先缩小一半,再放大一倍,效果就是变模糊了):
$convert image.png -resize 50%
-resize 200%
resize.png
3,放大,缩小 -sample
与resize的区别在于-sample只进行了采样,没有进行插值,所以用来生成缩略图最合适
$convert image.png -sample 50% sample.png
这个处理的效果就是马赛克:
$convert image.png -sample 10% -sample 1000% sample.png
4,裁剪 -crop
从(50,50)位置开始,裁剪一个100X100大小的图片:
$convert image.png -crop 100x100+50+50 crop.png
如果不指定位置,则按照这个大小分隔出小图片,这个命令生成crop-0.png,crop-1.png,crop-2.png……:
$convert image.png -crop 100x100 crop.png
可以指定裁剪位置的相对位置 -gravity:
$convert image.png -gravity northeast -crop 100x100+0+0 crop.png
-gravity即指定坐标原点,有northwest:左上角,north:上边中间,northeast:右上角,east:右边中间……
5,旋转 -rotate
$convert image.png -rotate 45 rotate.png
默认的背景为白色,我们可以指定背景色:
$convert image.png -backround black -rotate 45 rotate.png
$convert image.png -background #000000 -rotate 45 rotate.png
还可以指定为透明背景色:
$convert image.png -background rgba(0,0,0,0) -rotate 45 rotate.png
合并指的是将一张图片覆盖到一个背景图片上:
$convert image.png -compose over overlay.png -composite newimage.png
-compose指定覆盖操作的类型,其中over为安全覆盖,另外还有xor、in、out、atop等等
覆盖的位置可以通过-gravity指定:
$convert image.png -gravity southeast -compose over overlay.png -composite newimage.png
这是将图片覆盖到底图的右下角。
7,更改图片的alpha通道
$convert image.png -define png:format=png32
image32.png
$convert image32.png -channel alpha -fx &0.5& imagealpha.png
这个命令首先将image.png的格式改为png32(确保有alpha通道),然后更改alpha通道置为0.5,也就是半透明,值的范围为0到1.0
可以使用将一张透明图片覆盖到原图上的方式做水印图片:
$convert image.png -gravity center -compose over overlay.png -composite newimage.png
$convert image.png -gravity southeast -compose over overlay.png -composite newimage.png
横向拼接(+append),下对齐(-gravity south):
$convert image1.png image2.png image3.png -gravity south +append result.png
纵向拼接(-append),右对齐(-gravity east):
$convert image1.png image2.png image3.png -gravity east -append result.png
9,格式转换
$convert image.png image.jpg
$convert image.png -define png:format=png32 newimage.png
10,文字注释
$convert image.png -draw &text 0,20 'some text'& newimage.png
从文件text.txt中读取文字,指定颜色,字体,大小,位置:
$convert source.jpg -font xxx.ttf -fill red -pointsize 48 -annotate +50+50 @text.txt result.jpg
11,去掉边框
$convert image.png -trim -fuzz 10% newimage.png
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:193742次
积分:3061
积分:3061
排名:第8098名
原创:112篇
转载:30篇
评论:27条
(3)(1)(14)(15)(17)(18)(10)(15)(24)(14)(11)

我要回帖

更多关于 wamp安装imagick 的文章

 

随机推荐